-3

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.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 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

Community
  • 1
  • 1
hugo
  • 27
  • 2
  • 4

2 Answers2

0

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

Dr.Molle
  • 116,463
  • 16
  • 195
  • 201
0

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.

Vlad
  • 10,602
  • 2
  • 36
  • 38