I am trying to build a program to select at most 5 search result, search them in google and open it up in the browser. However, "soup.select('.r a')" in the program returns an empty list.
import requests
import sys
import webbrowser
import bs4
res=requests.get('http://google.com/search?q='+'Python'.join(sys.argv[1:]))
res.raise_for_status()
soup=bs4.BeautifulSoup(res.text,'html.parser')
linkElements=soup.select('.r a')
linkToOpen=min(5,len(linkElements))
for i in range(linkToOpen):
webbrowser.open('https//google.com'+linkElements[i].get('href'))
The code runs without any error and without any output but does not open the browser with search results as it was supposed to do.