Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Google search
#1
Hi everyone,
I am just playing around with Python3 and I wonder how I can open a browser and search for something automatically. I found some ideas on just open a browser or just search for something and display it than in terminal but I would like to have it like the Google Assistant or Siri. Not with speech input but with the same result. I hope you guys understand what I mean!

Thanks
Reply
#2
No so many lines if use webbrowser to open a browser.
import webbrowser

search_word = 'car'
url = "https://www.google.com/search?q={}".format(search_word)
webbrowser.open_new_tab(url)
Reply
#3
Wow thanks it works perfect but I am using it on Linux and the terminal opens:

*** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: telemetry_modules_ping

Any chance to avoid it or is it just skipped if something follows the command?
Reply
#4
I run Debian 9 and the above sample runs well.
Reply
#5
Don't you get the same thing if you close the Browser and wait a few seconds?
Reply
#6
No, I do not get any error message after closing my browser (firefox 52)
Reply
#7
Well, I got another problem now what is the url of google images I can't figure it out. Not the url but how to input the text and search for it? With the example below it works with "regular" google.

import webbrowser
 
search_word = 'car'
url = "https://www.google.com/search?q={}".format(search_word)
webbrowser.open_new_tab(url)
Reply
#8
Change to.
url = "https://www.google.com/search?tbm=isch&q={}".format(search_word)
Reply
#9
No that doesn't work it just opens google images without input
Reply
#10
What to you mean with no input?
import webbrowser

search_word = 'car'
url = "https://www.google.com/search?tbm=isch&q={}".format(search_word)
webbrowser.open_new_tab(url)
It switch to google images and search for car.
tbm=vid would switch to video.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to import files in Google Collab wihout downloading them to PC and to Google Disk sveto4ka 9 3,804 Jun-03-2020, 12:40 PM
Last Post: sveto4ka
  Search "Places near by me" or "where am I" in google maps barry76 1 2,650 Feb-07-2019, 04:10 PM
Last Post: snippsat
  Can I search from Python, automatically and randomly generated keywords in Google? xX_Prophit_Xx 0 2,270 Sep-07-2018, 04:43 PM
Last Post: xX_Prophit_Xx
  google search by Python klim1167 3 84,803 Jul-12-2017, 01:52 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020