Skip to content Skip to sidebar Skip to footer

Sending An Jquery Ajax Get Request With Python Request Library

I have a website I need to scrape and it is using jquery AJAX function to get information from the server. I have been investigating the code for a while and I successfully get the

Solution 1:

Solved it! I added 'X-Requested-With': 'XMLHttpRequest' to headers and did:

pn = '1234'
r = requests.get(ajaxurl + '?part_number=' + pn, headers=headers, cookies=cookies)

Did not understand why though :(


Solution 2:

BAD REQUEST 400 means that the server was unable to understand or process your request (the data you sent via AJAX).

Since you're using GET method in AJAX, I would give a try to traditional url with query string:

var request = 'part_number=1234';
$.get('http://your.website/your_server_file?'+request, function(data){
    // handle the server response (data) here ...
});

Post a Comment for "Sending An Jquery Ajax Get Request With Python Request Library"