Невозможно найти «Next» в таблице в Google с помощью urllib. Пробовал с тэгом: tbody, td и tr, но не знаю, как разобрать внутренние тэги. Код написан ниже:
def extracter(url,key,change):
if " " in key:
key=key.replace(" ",str(change))
url=url+str(key)
response=ur.Request(url,headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'})
sauce =ur.urlopen(response).read()
soup=bs(sauce,"html.parser")
return soup
def google_next(key):
url = "https://www.google.com/search?q="
soup = extracter(url ,key,"+")
print(soup.findAll("a",{"class":"pnnext"}))
google("games")
Вывод:
response = meth(req, response)
File "C:\Users\loveislife\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Users\loveislife\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "C:\Users\loveislife\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Users\loveislife\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 429: Too Many Requests