本帖最后由 城中城 于 2020-9-17 22:14 编辑
import requests
url = 'https://accounts.douban.com/j/mobile/login/basic'
data = {}
data['ck'] = 'ge4y'
data['name'] = '豆瓣账号'
data['password'] = '豆瓣密码'
data['remember'] = 'false'
header = {}
header['Accept'] = 'application/json'
header['Content-Type'] = 'application/x-www-form-urlencoded'
header['Referer'] = 'https://accounts.douban.com/passport/login'
header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3775.400 QQBrowser/10.6.4208.400'
header['X-Requested-With'] = 'XMLHttpRequest'
res = requests.post(url, data = data, headers = header)
url = 'https://www.douban.com/'
res = requests.get(url, cookies = res.cookies, headers = header)
print(res.text)
了却了我一个心结,虽然不用直接抓cookies,但是抓取了很多其他的东西,个人感觉如果给自己用的话 还不如抓cookies来得方便
以上图为证 也感谢上面俩大佬的教导 |