简体   繁体   English

刮下XHR请求

[英]Scraping next page XHR request

I want to scrape the second page of this user reviews . 我要抓取该用户评论的第二页。

However the next button executes a XHR request, and while I can see it using Chrome developer tools, I cannot replicate it. 但是,下一个按钮将执行XHR请求,尽管我可以使用Chrome开发者工具看到该请求,但无法复制它。

It's not so easy task. 这不是一件容易的事。 First of all you should install this extension . 首先,您应该安装此扩展 It helps you to test own requests based on captured data, ie catch and simulate requests with captured data. 它可以帮助您根据捕获的数据测试自己的请求,即使用捕获的数据捕获和模拟请求。

As I see they send a token in this XHR request, so you need to get it in from html page body(stores in source code, js variable "taSecureToken" ). 如我所见,他们在此XHR请求中发送了令牌,因此您需要从html页面正文(源代码中存储的js变量“ taSecureToken”)中获取令牌。

Next you need to do four steps: 接下来,您需要执行四个步骤:

  1. Catch POST request with plugin 使用插件捕获POST请求
  2. Change token to saved before 将令牌更改为保存之前
  3. Set limit and offset variables in POST request data 在POST请求数据中设置limitoffset变量
  4. Generate request with resulted body 生成带有结果正文的请求

Note: on this request server returns json data(not the html with next page) containing info about loaded objects on next page. 注意:在此请求服务器上,返回json数据(而不是带有下一页的html),其中包含有关下一页上已加载对象的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM