automatestuff-ja icon indicating copy to clipboard operation
automatestuff-ja copied to clipboard

The code provided no longer works

Open Shige1962 opened this issue 4 years ago • 0 comments

Here is the code that works.

import webbrowser, requests, bs4 , sys

print('Googling...')
res = requests.get('https://google.com/search?q=' + ' '.join(sys.argv[1:]))
res.raise_for_status()

soup = bs4.BeautifulSoup(res.text)

linkElems = soup.select('div#main > div > div > div > a')  
numOpen = min(5, len(linkElems))
for i in range(numOpen):
    webbrowser.open('http://google.com' + linkElems[i].get("href"))

I hope it helps.

Shige1962 avatar Jul 08 '21 15:07 Shige1962