I'm scraping the following website Scorebing using requests. In order to do so, I'm exploring the website to locate the XHR calls and get an url like this
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()
No problems there. My problem is that if I switch tab, like from Corner to Fixture, no new XHR is called. In fact, only "Live Matches" and "Corners" allows for this direct XHR connection. I see that some js scripts are loaded, but I can't go from there to replicating my previous step.
I know I can scrape this using selenium, and probably using a regular requests to the url of the page and using BSoup, but what I don't understand is why some tabs make XHR calls to load data where other similar ones use js. I would like to know how can you reverse engineer those js calls in order to get an API similar to the first part.


Firstly,you should know that
XHR(XMLHttpRequest) in Chrome will record all theajaxrequest.What's
Ajax?Ajax could be achieved by
JavaScriptorjQuery(Well,jQuery is a JavaScript library.It is JavaScipt essentially,but jQuery offer a API aboutajax).In your example page,there are many ajax requests in the source code:
If you really want to do it just by the source code,you should:
GETrequest to the page.Javascript.(Also sendGETrequest.)GETrequests,select the data you need from them.