I am trying scrape data from a AJAX web interface site. Link to that website is as follows:
To do so I used the following code:
import requests
request_url = 'https://dps.psx.com.pk/webpages/history_bySymbol.php?op=4'
data = {'sday': '01', 'mth':'10', 'yr':'2012','symcode':'ENGRO'}
headers = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/61.0.3163.79 Chrome/61.0.3163.79 Safari/537.36'}
r = requests.post(request_url, data=data, headers=headers)
print(r.text)
Now the problem is when I print the text I am unable to get data which is supposed to be generated by entering 4 parameters.
What might be wrong with the code?
Edit: Issue is that when I open the above webpage, on top there is a drop down menu for market data, from there I select historical data. Link in the chrome bar remains the same since it is an AJAX web interface. My goal is to scrape historical data for that I am using above mentioned code. Using chrome's developer tools I looked at what ajax key was added when I requested for historical data. From there I found out it took four parameters as mentioned in the above code (XHR subsection to Headers). I expect that when I run the code it should provide me with historical data somewhere in r.text, but it doesn't. I need the data as shown in the image. I expected that above code to give these values but it didn't.