Google Sheets IMPORTHTML "Could not fetch data"

Viewed 91

I'm trying to figure out why all of a sudden my importhtml links are not working anymore and they say "Could not fetch data from url".

Here the link to the site https://www.baseball-reference.com/players/split.fcgi?id=wheelza01&year=Career&t=p

On that site scroll down to 'Batting Order Positions' and then im trying to just pull tOPS+ data. Is there any way i can use XML? I was just using the link in the embed table for importhtml and it was working before

Any help much appreciated

2 Answers

the site you are trying to scrape undergo "JS modernization" and google sheets cant import JavaScript elements. you can test this like:

enter image description here

and see that values you try to import are not present

The data are masked by

<!-- ... -->

, nevertheless you can retrieve them by this way

=importxml(A1,"//div[@class='table_wrapper setup_commented commented']")

assuming in A1 you have your url. If you only need 'Batting Order Positions', then try

=query(importxml(A1,"//div[@class='table_wrapper setup_commented commented']"),"select Col3 where Col3 contains 'Batting Order Positions' ")

Then you have to split the response to get a clean table.

enter image description here

Related