开发者

Extract any links from the Google search with javascript [duplicate]

开发者 https://www.devze.com 2023-03-20 01:18 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How extract links from iframe using javascript
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How extract links from iframe using javascript

http://www.google.cl/search?q=food SOURCE CODE:

<html><head>...<img src="GOOGLE LOGO">...
...
<a href="http://www.SE开发者_如何学GoARCH 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 OUTPUT:

the third search result from google is:

http://www.SEARCH RESULT 3.org

the fifth search result from google is:

http://www.SEARCH RESULT 5.us

experimental_test.html SUPPOSED source code:

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

In other words, I want to extract the specific links, like the second link in the search. Without wanting to use PHP


You may not extract something, because you don't have any access to the document inside the iframe.


In short you can't and you shouldn't.

You can't because you're not allowed to use your script to manipulate data from other website.

You shouldn't because it's against Google's TOS to scrape the search results. You should use the Custom Search API.

0

精彩评论

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