why getting error likeHTTP Error 405 Method Not Allowed?

by: afamrk, 6 years ago


import urllib.parse
import urllib.request
headers={}
headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
url = 'https://www.google.com/search'
values = {'q' : 'python programming tutorials'}
data = urllib.parse.urlencode(values)
data = data.encode('utf-8')
req = urllib.request.Request(url,data,headers=headers)
resp = urllib.request.urlopen(req)
respData = resp.read()

print(respData)



You must be logged in to post. Please login or register an account.



IIRC, Google doesn't allow for this anymore. Try using the search on this site instead

For example, to search for "test" you would want to build the following url:

https://pythonprogramming.net/search/?q=test

-Harrison 6 years ago

You must be logged in to post. Please login or register an account.