Skip to content
Advertisement

XHR Request Preview Shows Data That Isnt Present In Response

I am trying to use scrappy to grab some data off of a public website. Thankfully the data mostly can be found in an xhr request here: enter image description here

But when I double click to see the actual response there is no data in the search_results item:

enter image description here

I am just wondering what is going on with the request, how can I access this data in scrapy, currently im trying to like this but obviously its not grabbing any of the data from the response.

JavaScript

Advertisement

Answer

Actually, response is just working fine and your coding structure is also fine. You are getting json data from API as POST method.So in order to pull data correctly, It’s mandatory to inject content-type headers and payload data as body parameter in request method.

An example with full working solution:

JavaScript

Output:

JavaScript
Advertisement