Python Forum

Full Version: Google search
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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
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)
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?
I run Debian 9 and the above sample runs well.
Don't you get the same thing if you close the Browser and wait a few seconds?
No, I do not get any error message after closing my browser (firefox 52)
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)
Change to.
url = "https://www.google.com/search?tbm=isch&q={}".format(search_word)
No that doesn't work it just opens google images without input
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.
Pages: 1 2