jeudi 4 juillet 2019

i tried to make a simple python auto google search but its not working im not sure why

i dont know what to try because im not getting any error messages its just blank when i run it, i was following along with a guy on youtube and his worked

import requests
import bs4
import sys
import webbrowser

search = 'savage'
res = requests.get(f'https://google.com/search?q={search}')
res.raise_for_status()

soup = bs4.BeautifulSoup(res.text, 'html.parser')
linkelem = soup.select('.r a')
linkstoopen = min(5, len(linkelem))

for i in range(linkstoopen):
    webbrowser.open('https://google.com', linkelem[i].get('href'))

it is supposed to open up the top 5 results for "savage" on google




Aucun commentaire:

Enregistrer un commentaire