Search on blog:

Python: How to use Selenium with local HTML in string.

To run Selenium on local HTML which you have in string you can use

driver.get("data:text/html;charset=utf-8," + html)

Full example

html = '''
<ul>
  <li>Contains Enzymatically Active B-Vitamins
  </li>
  <li>Dietary Supplement
  </li>
  <li>Non-GMO LE Certified
  </li>
</ul>'''

import selenium.webdriver

driver = selenium.webdriver.Firefox()

driver.get("data:text/html;charset=utf-8," + html)

elements = driver.find_elements_by_tag_name('li')

elements = [i.text for i in elements]

print( ", ".join(elements)) 
If you like it
Buy a Coffee