Python Forum
Google search - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Google search (/thread-6499.html)

Pages: 1 2


Google search - hello_its_me - Nov-25-2017

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


RE: Google search - snippsat - Nov-25-2017

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)



RE: Google search - hello_its_me - Nov-25-2017

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?


RE: Google search - heiner55 - Nov-26-2017

I run Debian 9 and the above sample runs well.


RE: Google search - hello_its_me - Nov-26-2017

Don't you get the same thing if you close the Browser and wait a few seconds?


RE: Google search - heiner55 - Nov-26-2017

No, I do not get any error message after closing my browser (firefox 52)


RE: Google search - hello_its_me - Nov-26-2017

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)



RE: Google search - snippsat - Nov-26-2017

Change to.
url = "https://www.google.com/search?tbm=isch&q={}".format(search_word)



RE: Google search - hello_its_me - Nov-27-2017

No that doesn't work it just opens google images without input


RE: Google search - snippsat - Nov-27-2017

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.