使用javascript从谷歌搜索中提取任何链接

Extract any links from the Google search with javascript

本文关键字:提取 任何 链接 搜索 javascript 谷歌 使用      更新时间:2023-09-26

可能重复:
如何使用javascript 从iframe中提取链接

http://www.google.cl/search?q=food源代码:

<html><head>...<img src="GOOGLE LOGO">...
...
<a href="http://www.SEARCH RESULT 1.com"> RESULT FOR FOOD 1</a>
<a href="http://www.SEARCH RESULT 2.net"> RESULT FOR FOOD 2</a>
<a href="http://www.SEARCH RESULT 3.org"> RESULT FOR FOOD 3</a>
<a href="http://www.SEARCH RESULT 4.com"> RESULT FOR FOOD 4</a>
<a href="http://www.SEARCH RESULT 5.us"> RESULT FOR FOOD 5</a>
...
</html>

experimental_test.html输出:

谷歌的第三个搜索结果是:


http://www.SEARCHRESULT 3.org

谷歌的第五个搜索结果是:


http://www.SEARCH结果5.us

experimental_test.html提供的源代码:

<iframe style="display:none;" src="http://www.google.cl/search?q=food">
<script>
...ge
</script>

换句话说,我想提取特定的链接,就像搜索中的第二个链接。不想使用PHP

您可能无法提取某些内容,因为您无法访问iframe中的文档。

简而言之,你不能也不应该。

你不能,因为你不允许使用你的脚本来操纵其他网站的数据。

你不应该这样做,因为抓取搜索结果违反了谷歌的TOS。您应该使用自定义搜索API。