0

I know it's possible to open up specific URL's with python's webbrowser module. Is it possible to use strings as search queries with it, or another module? Say in an engine like Google or Yahoo?

3 Answers 3

1

Of course it's possible - they're just GET requests. So long as you format the URL properly with the query string correct and all (http://google.com/search?q=query - look at the site to see what it needs to be), it'll work fine. It's just a URL.

Sign up to request clarification or add additional context in comments.

3 Comments

It is just a URL, but you should take care of HTTP headers as well. User-agent, for example.
@khachik: not relevant - webbrowser opens the page in the user's browser. It's not urllib2.urlopen.
My fault, I thought you suggest to open the URL using something else, e.g. urllib, sorry.
0

You might want to look at mechanise if you want to automate webpages. You could also generate your own search url and then call it in webbrowser or urllib See: http://www.our-picks.com/archives/2007/01/30/google-search-urls-revealed-or-how-to-create-your-own-search-url/

Comments

0

If you want to search with webbrowser, and allows user to input, this code might helps you.

import webbrowser

question = input("Input your question:")
webbrowser.open("https://www.google.com/search?q=" + str(question))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.