Chris Moretti
Chris Moretti

Reputation: 607

Google Sheets IMPORTXML Text Field from Website

I am trying to dynamically pull in car values for cars matching specific criteria on Kelley Blue Book. I have this IMPORTXML query that has a link to the specific page that shows the trade-in value of the car.

=IMPORTXML("https://www.kbb.com/Api/3.9.462.0/71553/vehicle/upa/PriceAdvisor/meter.svg?action=Get&intent=trade-in-sell&pricetype=FPP&zipcode=12345&vehicleid=411852&selectedoptions=6762567|true|6762674|false|6762900|false|6762905|false|6762909|false|6762913|false|6762915|true|6762926|false|6762928|false&hideMonthlyPayment=False&condition=verygood&mileage=40000", "//text[@y='-8']")

In this URL, there is a text field that has the y coordinate as -8. I was hoping that it would be sufficient to identify the data I want to pull in (The trade-in value). I get the standard Can't fetch URL error and can't figure out why.

Upvotes: 1

Views: 741

Answers (1)

player0
player0

Reputation: 1

the issue is not within your XPath "//text[@y='-8']" but with the website itself.

basically you have two options to test if the website can be scraped:

=IMPORTXML("URL", "//*")

where XPath //* means "everything that's possible to scrape"

and direct source code scrape method:

=IMPORTDATA("URL")

sometimes is source code just huge and Google Sheets can't handle it so this needs to be restricted a bit like:

=ARRAY_CONSTRAIN(IMPORTDATA("URL"), 10000, 10)

anyway, non of these can scrape anything from your URL

Upvotes: 2

Related Questions