从 Google 搜索中获取 URL 和标题
从给定的 Google 搜索词获取 URL 和标题的最简单方法是什么?我只想使用特定术语执行一次此操作,并且我想获取所有 URL/标题,而不是前 10 个。如果有一种方法可以获取分隔的响应(例如,以 CSV 格式),那就太理想了。
我并不是想重新发明轮子,但如果有必要,我愿意这样做(我在 Windows 机器上,我可以用 PHP 编写脚本)。我只是在寻找最快、最可靠、最常见的方法。
更新:到目前为止,这些建议似乎需要适量的编码,既可以解析 HTML/XML,也可以循环通过结果集(增加开始变量,单击“下一步”)。没有现有的程序可以快速做到这一点吗?
What's the simplest way to get the URL's and Titles from a given Google search term? I only want to do this once, with a specific term, and I want to get all the URLs/Titles, not the first 10. If there's a way to get the response delimited (e.g. in CSV format) that'd be ideal.
I'm not trying to reinvent the wheel, but if that's necessary I'm game to do it (I'm on a Windows box and I can script in PHP). I'm just looking for the fastest most reliable, common way of doing this..
Update: The suggestions thus far seem to require a modest amount of coding, both to parse HTML/XML, and to cycle through result sets (upping the start variable, to click "next"). Isn't there an existing program out there to quickly do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有很多方法可以做到这一点。你说你懂PHP,那为什么不使用cURL和一些正则表达式呢?
生成的源将位于 $data 中。从那时起,您可以使用 preg_match() 来收集您想要的 URL需要并将它们存储在数组中。或者,您可以尝试使用 XML 解析器更清洁的方法。
请注意,您可以修改 start=0 以返回其他结果。
There are many ways to do this. You say you know PHP, so why not use cURL and some regular expressions?
The resulting source will be in $data. From that point you can use preg_match() to gather the URLs you need and store them in an array. Alternatively, you could try an XML parser for a cleaner approach.
Note that you can modify the start=0 to return additional results.
您可以从 Google 搜索返回 xml 数据:
查看 http://www.google .com/cse/docs/resultsxml.html#XML_Results_for_Regular_and_Advanced_Search_Queries
You can return xml data from a google search:
Check out http://www.google.com/cse/docs/resultsxml.html#XML_Results_for_Regular_and_Advanced_Search_Queries