【发布时间】:2015-03-18 10:07:14
【问题描述】:
我想向linkedin.com 进行身份验证并获取一些内容
我使用requests python 模块并执行以下操作:
import requests
from BeautifulSoup import BeautifulSoup
client = requests.Session()
HOMEPAGE_URL = 'https://www.linkedin.com'
LOGIN_URL = HOMEPAGE_URL + '/uas/login-submit'
html = client.get(HOMEPAGE_URL).content
soup = BeautifulSoup(html)
csrf = soup.find(id="loginCsrfParam-login")['value']
login_information = {
'session_key':'my_login',
'session_password':'my_password',
'loginCsrfParam': csrf,
}
client.post(LOGIN_URL, data=login_information)
content = client.get(HOMEPAGE_URL + 'vsearch/c').content
而且,内容,好的,
但是,现在我想使用 tornado 框架来做同样的工作
我以类似的方式得到loginCsrfParam并发出post请求:
login_information = {
'session_key':'my_login',
'session_password':'my_password',
'loginCsrfParam':csrf
}
body = urllib.urlencode(login_information)
http_client.fetch(LOGIN_URL,
handle_request_post,
method='POST',
headers=None,
body=body)
并在收到响应后
http_client.fetch(HOMEPAGE_URL + '/vsearch/c',
handle_request_get_content,
method = 'GET')
但我得到的只是一个登录页面
怎么了?
【问题讨论】: