0

I'm trying to crawl sites like google for a project and I keep on getting 403 errors. some sites work and others don't. none of the sites that i'm using have a apis other than google so thats out the window. any thoughts

FNLURL = "https://www.google.com/search?q=test"

try:
    x = urllib.request.urlopen(FNLURL)
    req = urllib.request.Request(FNLURL, headers={'User-Agent': 'Mozilla/5.0'})
    resp = urllib.request.urlopen(req)
    respData = resp.read()
    print(respData)

except Exception as t:
    print(str(t))
Chanヨネ
  • 809
  • 1
  • 8
  • 11

0 Answers0