Script to open google search in browser

I am a beginner programmer whose experience is limited to writing very simple Python programs. For part of my first "real" project, I would like to write a script that takes input and opens a browser window with a google search for that input. I am at sea how to do it; I've looked for options with scripts like this one , but this outputs the results by printing them to the console; for my purposes, I would like the search results box for the query to be opened in the output (eventually I would also like the script to take a screenshot of the browser window and paste it into the Word document, but one thing at a time).

+3


source to share


1 answer


Opening a web page in Python is pretty easy.

import webbrowser
url = "https://www.google.com.tr/search?q={}".format(search_term)    
webbrowser.open(url)

      



For a little more reliability, you can pass the search_term to the urlencode

.

+8


source







All Articles