Sending an jquery AJAX GET request with Python request library

后端 未结 2 1962
暖寄归人
暖寄归人 2021-01-03 07:10

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

相关标签:
2条回答
  • 2021-01-03 07:48

    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 ...
    });
    
    0 讨论(0)
  • 2021-01-03 07:54

    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 :(

    0 讨论(0)
提交回复
热议问题