中级会员
- 威望
- 72
- 贡献
- 72
- 热心值
- 0
- 金币
- 216
- 注册时间
- 2021-8-29
|
10金币
http://www.yinsuwang.com/exam/catalogue.html?id=2
想爬免费的题库,但是获取不到
图片中的数据就是我想要的,但是python,总是无法获得
import requests
import json
headers ={"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection":"keep-alive",
"Content-Length": "24",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Cookie": "PHPSESSID=6e7e1dl6h5lu8sd28lio5rbge2",
"Host": "www.yinsuwang.com",
"Origin": "http://www.yinsuwang.com",
"Referer": "http://www.yinsuwang.com/exam/taste.html?id=2&exam_id=14375",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"}
data = "{'key':'value'}"
url = "http://www.yinsuwang.com/api/taste/get.json"
response = requests.post(url,data=data,headers=headers)
print(response.text)
|
-
最佳答案
查看完整内容
替换下cookie,访问exam_id=14441,是可以访问的,可能14408本来就是登录才能访问的资源
import requests
import json
headers ={
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Cookie": "xxxxxxxxxxxxxxxx",
"Host": "www.yinsuwang.com",
"Origin": "http://www.yinsuwang.com",
"Referer": "http://www.yinsuwang.com/exam/taste.html?id=2&exam_id=14441",
"User-Agent": "Mozilla/5 ...
|