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