I am trying to figure out what I\'m doing wrong here, but I keep getting lost...
In python 2.7, I\'m running following code:
>>> import requ
One thing that is different with the browser request is the User-Agent; however you can alter it using requests like this:
url = 'https://www.zomato.com/praha/caf%C3%A9-a-restaurant-z%C3%A1ti%C5%A1%C3%AD-kunratice-praha-4/daily-menu'
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.90 Safari/537.36'}
response = requests.get(url, headers=headers)
print(response.status_code) #should be 200
Some web applications will also check the Origin
and/or the Referer
headers (for example for AJAX requests); you can set these in a similar fashion to User-Agent
.
headers = {
'Origin': 'http://example.com',
'Referer': 'http://example.com/some_page'
}
Remember, you are setting these headers to basically bypass checks so please be a good netizen and don't abuse people's resources.