Write a Python script to take a product name as input and then automatically google search reviews for it and open the top 3 search results in different tabs

#! python3
import bs4import webbrowser as wbimport requests as rq
print('Enter the product name: ')product = input()
print("Searching")print('opening tabs')res = rq.get('https://www.google.co.uk/search?q='+''.join(product)+ ' reviews')res.raise_for_status()
soup=bs4.BeautifulSoup(res.text, "html.parser")links = soup.select('.r a')
top3 = min(3,len(links))
for counter in range(top3):  wb.open('http://google.com' + links[counter].get('href'))

MA

Related Python Mentoring answers

All answers ▸

Write a recursive function that takes any integer n and prints the nth Fibonacci number.


What can I do with Python?


Write a simple Python program that asks a user to input their age and name and then return the text: "Hi my name is *NAME*, and I am *AGE* years old."


Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.