1

I'm trying to scrape little data into an excel sheet from Wikipedia website using the ImportXML formula.

The XPath code I copied which I got it from the browser.

Here is the Wikipedia page. https://en.wikipedia.org/wiki/Chicago

Scraping the Latitude and longitude which is present on the page.

Screenshot:

xpath error

This is the code that I get from the browser XPath selector.

//*[@id="mw-content-text"]/div/table[1]/tbody/tr[11]/td/span[1]/span/a/span[1]/span/span[1]

Can you help me with the code and help me where I'm doing the wrong?

1 Answer 1

0

try:

=INDEX(IMPORTXML("https://en.wikipedia.org/wiki/Chicago", "//span[@class='geo-dms']"), 1)

0

Sign up to request clarification or add additional context in comments.

5 Comments

Hey mate, Little help.. Can you help me the code for extracting the anchor link to it too? I did tired to change the code to hyperlink class, it returns empty. This is the code I tried. =INDEX(IMPORTXML("en.wikipedia.org/wiki/Chicago", "//span[@class='external text']"), 1) Thanks
try: ="https:"&QUERY(IMPORTXML("https://en.wikipedia.org/wiki/Chicago", "//a/@href"), "where Col1 contains 'geohack' limit 1")
Just tried the script, too much of requests sending from excel sheet for wikipedia scraping is slowing down the process. Can you please help me get a Xpath code of that, So that I can scraping tools like screamingfrog to scrape it faster? Appreciate the help mate :)
try if this will be faster: ="https:"&QUERY(ARRAY_CONSTRAIN(IMPORTXML("https://en.wikipedia.org/wiki/Chicago", "//a/@href"), 40, 1), "where Col1 contains 'geohack' limit 1")
I just tried it on a new sheet, it's slower than previous one. It's still loading even after a wait of 1 minute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.