Using ImportXML to pull URL and anchor

Viewed 264

My goal is to scrape a link containing either a word "apple" or a word "pear", and for each scraped link I need to scrape the anchor.

At present I am using the following:

=IMPORTXML(A1,"//a/@href[contains(., 'apple')]") 

Unfortunately, I can only scrape the links containing apple. Still need to add another condition - "pear" and scrape the anchor.

Thank you for your help.

1 Answers

Try this:

=IMPORTXML(A1,"//a/@href[contains(., 'apple') or contains(., 'pear')]")
Related