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
Answered by Mankaran A. Python tutor

1480 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a program that takes a value x and then outputs x Fibonnaci numbers. E.g. if x=6 output would be 1 1 2 3 5 8


What are recursive functions and when should they be used?


Firstly, my question is not Python related, but maths A-level related. I don't know how to change that in my profile but I would like to only tutor maths GCSE and potentially A-level. My question: Integrate sin(x)^3 over x=0 and x=pi/2.


Create a program that checks for syntactical errors in an email address.


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences