python# -*- coding:utf-8 -*- import requests from bs4 import BeautifulSoup as bs loginurl = 'http://www.zhihu.com/' s = requests.session() headers = { 'Referer':'http://www.zhihu.com/', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36' } data = { '_xsrf': bs(s.get(loginurl, headers = headers).content).find(type='hidden')['value'], 'email': 'email', 'password': 'passworld', 'rememberme': 'y' } r = s.post(loginurl, data = data, headers = headers) print r.text
结果是:<html><title>403: Forbidden</title><body>403: Forbidden</body></html>
希望得到前辈们的指点,万分感谢!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我试了,还是不行啊。
我改了下代码,现在是报这个错:
<html><title>405: Method Not Allowed</title><body>405: Method Not Allowed</body></html>