Piggy
Piggy

Reputation: 151

Taking the urls of a google search

Is there any simple way to take all href from a google search page like the following:

https://www.google.gr/?gfe_rd=cr&ei=rWNxVtClOY7c-Qa46afIBA#q=R+Cran

I tried to use the following selector:

$("h3.r")

but it contains only an onmouse click.

Upvotes: 0

Views: 36

Answers (1)

Martin Wiboe
Martin Wiboe

Reputation: 2119

You can read the data-href attribute of the link rather than the actual href attribute.

To do this without jQuery, use:

document.getElementsByClassName('r')[0].childNodes[0].dataset.href

Change the first array index to iterate through the results.

Upvotes: 1

Related Questions