I have a list of keywords (['a', 'b', 'c']
) and I'd like to check which appear on a given page, using Selenium (ideally each with the number of occurrences).
The naive way would be to look for each separately using XPATH (//*[contains(text(),'a')]
) (or body text, page source etc.) but it seems to be an overkill to go over the entire page again and again for each of the strings.
I have quite a few sites to go over so I'd like to do it efficiently. Do I just get all text from the entire <html>
(so including the title and the description on top of the <body>
) and then perform all the searching on my own outside of the scope of Selenium (e.g. Rabin-Karp etc.) or is there a reasonable out of the box solution?