开发者

Python Web Search

开发者 https://www.devze.com 2023-01-26 22:05 出处:网络
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 开发者_如何学Cwith it, or another module? Say in an engine like Googl

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 开发者_如何学Cwith it, or another module? Say in an engine like Google or Yahoo?


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.


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/


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))
0

精彩评论

暂无评论...
验证码 换一张
取 消