我想通过使用请求库登录到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