mirror of
https://github.com/vysecurity/LinkedInt.git
synced 2025-12-06 17:02:19 +01:00
fixed login
This commit is contained in:
parent
e654a9ae16
commit
9688ffd739
1 changed files with 21 additions and 36 deletions
47
LinkedInt.py
47
LinkedInt.py
|
|
@ -7,7 +7,6 @@
|
|||
# --- Constrain to company filters
|
||||
# --- Addition of Hunter for e-mail prediction
|
||||
|
||||
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
|
|
@ -42,44 +41,30 @@ username = config.get('CREDS', 'linkedin_username')
|
|||
password = config.get('CREDS', 'linkedin_password')
|
||||
|
||||
def login():
|
||||
cookie_filename = "cookies.txt"
|
||||
cookiejar = cookielib.MozillaCookieJar(cookie_filename)
|
||||
opener = urllib2.build_opener(urllib2.HTTPRedirectHandler(),urllib2.HTTPHandler(debuglevel=0),urllib2.HTTPSHandler(debuglevel=0),urllib2.HTTPCookieProcessor(cookiejar))
|
||||
page = loadPage(opener, "https://www.linkedin.com/")
|
||||
parse = BeautifulSoup(page, "html.parser")
|
||||
URL = 'https://www.linkedin.com'
|
||||
s = requests.Session()
|
||||
rv = s.get(URL + '/uas/login?trk=guest_homepage-basic_nav-header-signin')
|
||||
p = BeautifulSoup(rv.content, "html.parser")
|
||||
|
||||
csrf = parse.find(id="loginCsrfParam-login")['value']
|
||||
|
||||
login_data = urllib.urlencode({'session_key': username, 'session_password': password, 'loginCsrfParam': csrf})
|
||||
page = loadPage(opener,"https://www.linkedin.com/uas/login-submit", login_data)
|
||||
|
||||
parse = BeautifulSoup(page, "html.parser")
|
||||
cookie = ""
|
||||
csrf = p.find(attrs={'name' : 'loginCsrfParam'})['value']
|
||||
csrf_token = p.find(attrs={'name':'csrfToken'})['value']
|
||||
sid_str = p.find(attrs={'name':'sIdString'})['value']
|
||||
|
||||
postdata = {'csrfToken':csrf_token,
|
||||
'loginCsrfParam':csrf,
|
||||
'sIdString':sid_str,
|
||||
'session_key':username,
|
||||
'session_password':password,
|
||||
}
|
||||
rv = s.post(URL + '/checkpoint/lg/login-submit', data=postdata)
|
||||
try:
|
||||
cookie = cookiejar._cookies['.www.linkedin.com']['/']['li_at'].value
|
||||
cookie = requests.utils.dict_from_cookiejar(s.cookies)
|
||||
cookie = cookie['li_at']
|
||||
except:
|
||||
print "[!] Cannot log in"
|
||||
sys.exit(0)
|
||||
|
||||
cookiejar.save()
|
||||
os.remove(cookie_filename)
|
||||
return cookie
|
||||
|
||||
def loadPage(client, url, data=None):
|
||||
try:
|
||||
response = client.open(url)
|
||||
except:
|
||||
print "[!] Cannot load main LinkedIn page"
|
||||
try:
|
||||
if data is not None:
|
||||
response = client.open(url, data)
|
||||
else:
|
||||
response = client.open(url)
|
||||
return ''.join(response.readlines())
|
||||
except:
|
||||
sys.exit(0)
|
||||
|
||||
def get_search():
|
||||
|
||||
body = ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue