dimanche 5 juillet 2020

Using IMPORTXML with IF and contains?

I am new to google sheets and I have been working with the IMPORTXML function for a few now. However, I am not sure if what I am trying to achieve is possible with this function.

Basically, I am trying to scrape data from a webpage using IMPORTXML Like So: =IMPORTXML("https://www.example.com/","//tr")

Now if that extracted tr contains an IMG child element, I want to scrape it using: =IMAGE(IMPORTXML("https://www.example.com/","//tr/td//img//@src"))

Otherwise, I want it to leave a blank cell or fill it with text such as "Blank"

I've been starting with something like this but I think I am way off. =ARRAYFORMULA(IF(ISBLANK(IMPORTXML("https://www.example.com/","//tr/td//img//@src")), "Blank", IMAGE(IMPORTXML("https://www.example.com/","//tr//td//img//@src"))))

The problem is I am able to just extract every cell that contains an image, but when it doesn't contain an image, it just skips over and fills the next cell. I want to make sure that excel can check this and leave an empty cell when tr does not contain an img.

Aucun commentaire:

Enregistrer un commentaire