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'))

Answered by Mankaran A. Python tutor

1421 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


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.


Sales is real Customers is integer startmainprog input Sales input Customers if ((Sales > 500) OR ((Sales > 300) AND (Customers>9))) then output “Bonus Awarded” else output “No Bonus” end if end subroutine. Sales = 600 Customers = 9, answer:


Write a recursive function to find the factorial of a number n.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences