以下是代码
import requests
from bs4 import BeautifulSoup as bs
zhihu='https://www.zhihu.com/#signin'
def login():
header = {
"Accept": "*/*",
"Accept-Encoding": "gzip,deflate",
"Accept-Language": "en-US,en;q=0.8,zh-TW;q=0.6,zh;q=0.4",
"Connection": "keep-alive",
"Content-Type": " application/x-www-form-urlencoded; charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36",
"Referer": "http://www.zhihu.com/"
}
s = requests.session()
cookie = bs(s.get('https://www.zhihu.com', headers=header).content).find(type='hidden')['value']
print(cookie)
post_data = {'_xsrf': cookie, 'password': 'xxx','captcha_type':'cn','remember_me': True,'email': 'xxxx'}
p=s.post(url=zhihu, data=post_data, headers=header)
print(p)
r = s.get(url=zhihu)
if __name__ == '__main__': # 程序运行入口
login()
1
virusdefender 2016-06-02 12:00:05 +08:00
模拟的还不像,被识别出来了。
|
2
CBBing OP @virusdefender 能指点一下吗?
|
3
CBBing OP 各位别光收藏哈,给点参考意见
|
4
lanshee 2018-07-10 17:31:13 +08:00
大侠后来呢?
|