python requests http response 500 (site can be reached in browser) -


i trying figure out i'm doing wrong here, keep getting lost...

in python 2.7, i'm running following code:

>>> import requests >>> req = requests.request('get', 'https://www.zomato.com/praha/caf%c3%a9-a-restaurant-z%c3%a1ti%c5%a1%c3%ad-kunratice-praha-4/daily-menu') >>> req.content '<html><body><h1>500 server error</h1>\nan internal server error occured.\n</body></html>\n' 

if open 1 in browser, responds properly. digging around , found similar 1 urllib library (500 error urllib.request.urlopen), not able adapt it, more use requests here.

i might hitting here missing proxy setting, suggested example here (perl file::fetch failed http response: 500 internal server error), can explain me, proper workaround one?

one thing different browser request user-agent; can alter using requests 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, gecko) chrome/54.0.2840.90 safari/537.36'} response = requests.get(url, headers=headers) print(response.status_code) #should 200 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -