How to fetch dimension through IMPORTXML from book website in Google sheets

Viewed 58

This is how I get a product details using google sheets

=IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","//ul[@class='biblio-info']//li//span") 

but I just need the Dimension. How can I fetch that?

I have been trying for 3 days but can't seem to figure it out. Thank you so much!

2 Answers

You can get the XPath with DevTools (F12) of Chrome.

=IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","/html/body/div[2]/div[5]/div/div/div[1]/div[3]/div/ul/li[2]/span")

Alternative:

=IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","//ul[@class='biblio-info']//li[2]//span")

To extract only the dimensions:

=TRIM(REGEXEXTRACT(IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","//ul[@class='biblio-info']//li[2]//span"),"^(.+)\|"))

Try (without the mass)

=query(split(query(IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","//ul[@class='biblio-info']"),"select Col2"),"|"),"select Col1")

or

=substitute(query(split(query(IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","//ul[@class='biblio-info']"),"select Col2"),"|"),"select Col1"),"Dimensions","")

or

=regexextract(query(split(query(IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","//ul[@class='biblio-info']"),"select Col2"),"|"),"select Col1"),"[0-9 x.]+")

or

=regexextract(IMPORTXML("https://www.bookdepository.com/Wings-of-War-James-P-Busha/9780760348529","//ul[@class='biblio-info']//li[2]//span"),"[0-9 x.m]+")
Related