SunMoon Hong
SunMoon Hong

Reputation: 15

How to import links from a website to google sheet?

I want to import urls from https://www.mastersportal.com/ranking-country/82/united-states.html to get all the links of best universities in USA.

However, when I use the importXML formula, like importXML("url", "//td[@class='OrganisationListing']/@href"), it doesn't work.

What should I do to fetch the links with google sheet import formula?

Thanks in advance.

Upvotes: 1

Views: 685

Answers (2)

Tanaike
Tanaike

Reputation: 201378

I believe your goal as follows.

  • You want to retrieve all hyperlinks from https://www.mastersportal.com/ranking-country/82/united-states.html.

In this answer, //td[@data-title='Universities']/a/@href is used as the xpath.

Modified formula:

=IMPORTXML("https://www.mastersportal.com/ranking-country/82/united-states.html","//td[@data-title='Universities']/a/@href")

Result:

In the current stage, it seems that 258 hyperlinks are retrieved.

enter image description here

Reference:

Upvotes: 2

Amit Agarwal
Amit Agarwal

Reputation: 11268

This will help:

=importXML("https://www.mastersportal.com/ranking-country/82/united-states.html", "//table//tr//a/@href")

enter image description here

Upvotes: 1

Related Questions