Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login on linkedin using selenium

I'm starting a small project to scrape linkedin data using selenium, the first thing I'm noticing is that the login page is not working the same way when I use selenium.

When I load the page manually on the brower I get this response:

enter image description here

But when I do the same using selenium the response is different, even when the url is the same:

enter image description here

I a manually click on "iniciar sesion" I get redirected to the lonin page:

enter image description here

But the url is the same, how can I directly load proper page or trick the site so It does not detect than I'm using selenium?

This is the code I currently have:

from selenium import webdriver
import datetime
import time
import argparse
import os

#Define the argument parser to read in the URL
parser = argparse.ArgumentParser()
parser.add_argument('-url', '--url', help='URL to the online repository of images')
args = vars(parser.parse_args())
url = args['url']
url = "https://www.linkedin.com/m/login/"


# Initialize the Chrome webdriver and open the URL
driver = webdriver.Firefox()
driver.get(url)

EDIT:

I found that this link loads the right page directly:

https://www.linkedin.com/uas/login?session_redirect=%2Fvoyager%2FloginRedirect%2Ehtml&fromSignIn=true&trk=uno-reg-join-sign-in
like image 502
Luis Ramon Ramirez Rodriguez Avatar asked Dec 07 '25 04:12

Luis Ramon Ramirez Rodriguez


1 Answers

Exactly! You should probably use the API to access the data sets you are after.

https://pypi.org/project/python-linkedin-v2/

See the link below for some additional ideas of how to move this forward.

How to use linkedin API with python

If you can't use the API, you probably shouldn't be doing this, at least not on LinkedIn. Good luck!!

like image 58
ASH Avatar answered Dec 08 '25 17:12

ASH