├── README.md ├── demo.py └── linkedin.py /README.md: -------------------------------------------------------------------------------- 1 | # LinkedIn Email Scraper 2 | A python class that can scrape LinkedIn profiles for emails. Developed by Tufayel_LUS 3 | 4 | # Prerequisites 5 | 1. Python any version 6 | 2. Installation of below module using command 7 |
pip install requests8 | 3. Account in LinkedIn for accessing private profiles 9 | 10 | # Usage 11 | Refer to demo.py for usage reference. You can modify it as you like. You can import the linkedin.py class file or modify it as per your needs. 12 | 13 | # Example Code For Guest Access 14 |
client = LinkedIn()16 | -------------------------------------------------------------------------------- /demo.py: -------------------------------------------------------------------------------- 1 | from linkedin import LinkedIn 2 | email = "someone@example.com" #set username 3 | password = "example_password" #set password 4 | target_profile = "https://www.linkedin.com/in/tufayel-ahmed-cse/" #set target profile url 5 | client = LinkedIn() 6 | if client.login(email, password): 7 | 8 | #for single profile 9 | print(client.singleScan(target_profile)) 10 | 11 | #for bulk list 12 | #profiles = ["PROFILE_URL_1","PROFILE_URL_2"] 13 | #print(client.bulkScan(target_profile)) 14 | else: 15 | print("Login Failed, please recheck login credentials") 16 | -------------------------------------------------------------------------------- /linkedin.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import re 3 | 4 | class LinkedIn: 5 | 6 | def __init__(self): 7 | self.s = requests.Session() 8 | self.headers = { 9 | "user-agent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 OPR/67.0.3575.97" 10 | } 11 | def login(self,email,password): 12 | try: 13 | sc = self.s.get("https://www.linkedin.com/login", headers=self.headers).text 14 | except: 15 | return False 16 | csrfToken = sc.split('csrfToken" value="')[1].split('"')[0] 17 | sid = sc.split('sIdString" value="')[1].split('"')[0] 18 | pins = sc.split('pageInstance" value="')[1].split('"')[0] 19 | lcsrf = sc.split('loginCsrfParam" value="')[1].split('"')[0] 20 | data = { 21 | 'csrfToken': csrfToken, 22 | 'session_key': email, 23 | 'ac': '2', 24 | 'sIdString': sid, 25 | 'parentPageKey': 'd_checkpoint_lg_consumerLogin', 26 | 'pageInstance': pins, 27 | 'trk': 'public_profile_nav-header-signin', 28 | 'authUUID': '', 29 | 'session_redirect': 'https://www.linkedin.com/feed/', 30 | 'loginCsrfParam': lcsrf, 31 | 'fp_data': 'default', 32 | '_d': 'd', 33 | 'showGoogleOneTapLogin': 'true', 34 | 'controlId': 'd_checkpoint_lg_consumerLogin-login_submit_button', 35 | 'session_password': password, 36 | 'loginFlow': 'REMEMBER_ME_OPTIN' 37 | } 38 | try: 39 | after_login = self.s.post("https://www.linkedin.com/checkpoint/lg/login-submit",headers=self.headers,data=data).text 40 | except: 41 | return False 42 | is_logged_in = after_login.split('
15 | client.singleScan(url_to_profile)