You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maintaining the login function is a cat/mouse game. Having Selenium launch a browser, allowing the user to login there, and then closing it to get the cookies would reduce a lot of pain and troubleshooting.
This would solve most issues that get opened, and also support 2FA.
The existing login() function could be reduced to something like this:
def login():
"""Creates a new authenticated session.
This now uses Selenium because I got very tired playing cat/mouse
with LinkedIn's login process.
"""
driver = webdriver.Firefox()
driver.get("https://linkedin.com/login")
# Pause until the user lets us know the session is good.
input("Press Enter after you've logged in...")
selenium_cookies = driver.get_cookies()
driver.quit()
# Initialize and return a requests session
session = requests.Session()
for cookie in selenium_cookies:
session.cookies.set(cookie['name'], cookie['value'])
return session
I'd also need to remove the username and password args.
I tried to test this just now, but ran into issues with Selenium and my Linux VM - probably either because it was Ubuntu using snaps as browsers, or because it was ARM64.
I can try to come back and test this later, but I am very open to help if someone else wants to give it a try.
The text was updated successfully, but these errors were encountered:
Tested on MacOS ARM64, should also work in Windows x86/64, Windows ARM64, and Linux x86/64. I understand Selenium is not fully working on Linux ARM64, which may be an issue.
Maintaining the login function is a cat/mouse game. Having Selenium launch a browser, allowing the user to login there, and then closing it to get the cookies would reduce a lot of pain and troubleshooting.
This would solve most issues that get opened, and also support 2FA.
The existing
login()
function could be reduced to something like this:I'd also need to remove the username and password args.
I tried to test this just now, but ran into issues with Selenium and my Linux VM - probably either because it was Ubuntu using snaps as browsers, or because it was ARM64.
I can try to come back and test this later, but I am very open to help if someone else wants to give it a try.
The text was updated successfully, but these errors were encountered: