Using Google Sheets importXML, I want to extract an xpath attribute value (the image URL) from:
<div style="display: block; background-image: url("https://www.etebg.net/UserFiles/pictures/E28BA835-34EC-C291-F627-856FE8B6DF90.jpg?cache&block&q=100&w=350&h=350");"></div> ```
From the site:
https://www.etebg.net/ro/search/p1/Căutare.html?q=%%
Trying /html/body/div[2]/div[2]/div/a/div[1]/div/@class it works to get the first value of class
but trying /html/body/div[2]/div[2]/div/a/div[1]/div/@style gets N/A
CodePudding user response:
try:
=ARRAYFORMULA(REGEXEXTRACT(QUERY(FLATTEN(IMPORTDATA(
"https://www.etebg.net/ro/search/p1/Căutare.html?q=%%")),
"where Col1 contains 'data-src'"), "(https.*jpg)"))
or directly images:
=ARRAYFORMULA(IMAGE(REGEXEXTRACT(QUERY(FLATTEN(IMPORTDATA(
"https://www.etebg.net/ro/search/p1/Căutare.html?q=%%")),
"where Col1 contains 'data-src'"), "(https.*jpg)")))