Search code examples
pythonpython-requestspython-requests-html

What parameters need to be put in the code in order to execute correctly the requests.post function?


What parameters need to be put in regards to this site (www.pyszne.pl) so that the requests function can be executed properly? I need to have a url which leads to the restaurants available under a specific postcode.

here is my code:

import requests

payload = {'myvaluestring':'30-529'}
r = requests.post('https://www.pyszne.pl', data=payload)

print(r.url)

I'm only receiving the same main page url https://www.pyszne.pl/


Solution

  • It's a GET situation, not POST. Try this:

    In [1]: import requests                                                                                                                                                                                            
    
    In [2]: r = requests.get("https://www.pyszne.pl/30-529")                                                                                                                                                           
    
    In [3]: r.url                                                                                                                                                                                                      
    Out[3]: 'https://www.pyszne.pl/restauracja-krakow-krakow-podgorze-30-529'
    

    I recommend you to do a search on web "what's the difference of HTTP POST and GET".