我想通過使用請求庫登錄到linkedin。環顧四周後,最好的方法是使用requests.Session()
我試圖做到這一點,但我沒有成功。 我認爲這與我發佈的鏈接有關。爲什麼不是請求無法正確登錄網站?
import requests
payload = {
'session_key': EMAIL_GOES_HERE,
'session_password': PASSWORD_GOES_HERE
}
with requests.Session() as s:
s.post('https://www.linkedin.com/', data=payload)
#program should be signed in here so I am going onto a private page that requeires the user to be signed in.
r=s.get('https://www.linkedin.com/vsearch/p?f_CC=2289109')
#saving the results in an HTML file for easy debugging/viewing
html= open('testtest.html', 'w')
html.write(r.content)
html.close()
這可能是因爲您的帖子格式化,但在'with'語句中放入'r = ...'和以下幾行。 – ThinkChaos