I am new to ajax and javascript.
I am crawling a website in which I am able to fetch relevant piece of details with the help of XPath after downloading webpage using Python(urllib2/request/mechanize).
In the webpage these are some information that is visible only after clicking a link. And that link calls XHR to fetch details that I found out using firefox's web developer tools. (Ctrl+Shift+Q or Tools >> Web Developer >> Network
) I am showing that link and its javascript attributes that I can see using Firefox web developer tool (Ctrl+Shift+C or Tools >> Web Developer >> Inspector
) in attached image under thick black rectanguls.
I am also able to see ajax request url, headers, response and parameters though same firefox web developer tools. same image is visible at https://i.stack.imgur.com/9jhfr.png
I am thinking that I have all the payload for POST request. How can I make http post call this using Python with the help of request/urllib2 etc? so in response I can see details which i show in webpage after clicking that link. Like
requests.get(url, data=<paramter_to_post which i can see in firefox>, headers=<request headers that I can see in firefox>)
I short
How to simulate ajax call using python? or how to fetch infromation which I see after clicking that link?
I can automate this task using Selenium/PhantomJS or other headless browser. but I want to solve this using HTTP Post and Get which is exactly happening in Firefox when I click the link.