抓取网站的XHR/JSON数据的问题
他的表格的数据是Ajax请求的背后。我仍在学习,但我不想求助于使用硒作为查看表元素,因此很难将数据排列到数据范围内。我该如何通过这样的网站来理解我将来应该寻找什么样的东西。
我尝试使用所有请求标头,但我仍然希望能够获取JSON数据。
The data for his table is behind ajax request. I'm still learning but I don't want to resort to using selenium yet as looking at the table element it's going to be hard to arrange the data into a data frame. How can I get this and what sort of things should I look for in the future with sites like these.
I have tried using all the request headers but I still want able to get the JSON data.
https://www.barchart.com/futures/quotes/ESU22/options/MI7N22
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要一个标题 x-xsrf-token 和其他cookie laravel_token 请求API。
你怎么能得到这个饼干?只有当您打开真实浏览器(Selenium或 playwright )并在可以将简单请求发送到API之后获取。
我从浏览器复制API卷发中得到了这些cookie。
在这里,您有一些示例代码:
输出:
也许您需要更改此cookie和标头的价值。 (我不知道它们有效多长时间,如果它们链接到我的IP地址)。
希望我能够为您提供帮助。
You need one header x-xsrf-token and other cookie laravel_token to request API.
How can you get this cookies? Only when you open real browser (selenium or playwright) and get them after you can send simple request to API.
I got this cookies from my browser copied API cURL.
Here you have some example code:
OUTPUT:
Maybe you will need to change the value of this cookie and header. (i don't know how long are they valid and if they are linked to my IP address).
I hope I have been able to help you.