简体   繁体   中英

How can I import an html attribute from a website into a google sheets document?

I want to have a readout for "data-original-title"

I tried this (H2 is the website link):

=IMPORTXML(H2;"//div[@id='mainContent']//dd[@class='col-6 col-xl-7'][1]

No readout but also no Error

Also tried this,

=IMPORTXML(H2;"//div[@id='mainContent']//dd[@class='col-6 col-xl-7']//attribute[@data-original-title]")

but got N/A

I think it just doesnt print the value of the attribute in google sheets, but Im unsure and not that familiar with xpath. Can anyone help?

I finally found the answer myself jsut by trial and error.

=IMPORTXML(H2;"//div[@id='mainContent']//dd[@class='col-6 col-xl-7']/span/@data-original-title")

This worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM