用 Python 做一个简单的雅虎搜索 [英] Doing a Simple Yahoo Search in Python

查看:34
本文介绍了用 Python 做一个简单的雅虎搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个 Python 脚本,该脚本在某一时刻执行 Yahoo 网络搜索以查找和下载一堆 C 源文件.我对此很陌生,我无法弄清楚如何开始进行简单的网络搜索......我已经看到了很多关于 BOSS 的东西,但是,根据我的理解,这是你需要的付费使用?我不愿意为此付出代价.

I need to write a Python script which, at one point, does a Yahoo web search to find and download a bunch of C source files. I'm very new to this and I can't figure out how to just get started with doing a simple web search... I've seen a lot of stuff about BOSS but, from my understanding, this is something you need to pay to use? I am not willing to pay for this.

我使用了 Python YQL 来获得一些 RSS 结果,如下所示:

I've used Python YQL to get some RSS results as follows:

import yql
y = yql.Public()
result = y.execute('select * from rss where url="http://www.un.org/apps/news/rss/rss_top.asp"');

for row in result.rows:
   print row.get('title')

这似乎有效,但我不知道如何进行普通的网络搜索(因为 search.web 表显然已经消失了).一个基本的工作示例将不胜感激.

And this seems to work, but I can't figure out how to just do a normal web search (since the search.web table is apparently gone). A basic working example would be much appreciated.

推荐答案

您可能想尝试使用 mechanize,模拟浏览器.如果您需要清除结果文件中的一些残留物,请使用 Beautiful Soup.

You might want to try it using mechanize, which simulates a browser. If you need to clean out some of the crud in the resulting files, use Beautiful Soup.

这篇关于用 Python 做一个简单的雅虎搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆