不同的 post value 应该得到不同的页面结果, 得到的结果却是一样的, 请教爬虫问题
时间: 2020-08-21来源:V2EX
前景提要
我想要抓取这个网站的数据, http://ouhe.aiball365.com/league-center/detail?leagueId=31
每次点击页面的时候, 后台会看到一个 post 请求, " http://backend.aiball365.com/web/leagueSummaryWeb "
我把 header 和 data 复制出来, 模拟一个请求的时候。 post data 为: {"channel":"web","os":"browser","leagueId":"31","season":"2019-2020","round":2}
这个 round 是根据比赛轮数变化的, 因为每一页都是一个新的轮数, 所以也可以认为一页修改一个 round 值。
我写的代码是这样的 import requests import json url = "http://backend.aiball365.com/web/leagueSummaryWeb" headers = { 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-US;q=0.7,ja;q=0.6', 'Content-Length': '69', 'Content-Type': 'application/json;charset=utf-8', 'Host': 'backend.aiball365.com', 'Origin': 'http://ouhe.aiball365.com', 'Proxy-Connection': 'keep-alive', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36', } for i in range(1, 3): data = {"channel": "web", "os": "browser", "leagueId": "31", "season": "2019-2020", "round": i} response = requests.get(url, headers=headers, data=json.dumps(data)) with open('{}.txt'.format(i), 'w+', encoding='utf-8') as the_file: the_file.write(response.text)
我这个代码应该获取到第一页和第二页的, 但是我实际上获取到的是第 32 页的而且两次获取的内容一样请问是怎么回事?

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行