How do i make my script google something in my default browser
Example:
a = input("What to google? ")
google(a)
#this should google the input in default browser
Thanx in advance!
How do i make my script google something in my default browser
Example:
a = input("What to google? ")
google(a)
#this should google the input in default browser
Thanx in advance!
If it's something fairly simple to google:
import webbrowser
a = input("What to google? ")
webbrowser.open('https://www.google.com/search?q={}'.format('+'.join(a.split())))
OR
import webbrowser
a = input("What to google? ")
webbrowser.open('https://www.google.com/search?q={}'.format(a.replace(' ', '+')))
For searching in google, let's say we want to search 'python program for windows'.
The url will be https://www.google.com/search?q=python+program+for+windows
. This shows that the space should be replaced with +
Here's the code:
import os
def google(a):
d = "https://google.com/search?q="
a = a.replace(' ','+')
os.system("start " + d + a)
a = input("what to google? ")
google(a)
print(a + " googled...")