我正在使用请求删除以下网站Scorebing。 为了做到这一点,我正在浏览该网站,以找到XHR调用并获得如下url
import requests,json
header={some data from the XHR I got using Postman}
url='https://lv.scorebing.com/ajax/score/data?mt=0&nr=1&corner=1'
response=requests.get(url=url,headers=header,data=json.dumps({}))
response.json()
没问题。我的问题是,若我切换选项卡,比如从角点切换到夹具,就不会调用新的XHR。事实上,只有“实时匹配”和“角落”允许这种直接的XHR连接。我看到加载了一些js脚本,但我不能从那里复制我的前一步
我知道我可以使用selenium来解决这个问题,可能还可以使用对页面url的常规请求和BSoup,但我不明白的是,为什么有些选项卡使用XHR调用来加载数据,而其他类似的选项卡则使用js。 我想知道如何对这些js调用进行反向工程,以获得与第一部分类似的API
首先,您应该知道Chrome中的
XHR
(XMLHttpRequest)将记录所有ajax
请求什么是
Ajax
Ajax可以通过
JavaScript
或jQuery
实现(好吧,jQuery是一个JavaScript库,本质上是JavaScipt,但jQuery提供了一个关于ajax
的API)在示例页面中,源代码中有许多ajax请求:
如果您真的只想通过源代码实现,您应该:
GET
请求李>Javascript
。(同时发送GET
请求。)GET
请求,从中选择所需的数据李>相关问题 更多 >
编程相关推荐