0

I am using Selenium with Python and want to access the plain HTML source code before it is parsed and the DOM is modified by the browser. I do not want to use "driver.page_source" as it is giving me back the DOM after parsing and for example dynamically created elements are included. I know I could do a second request with for example requests but I am looking for a way to extract it without doing an additional request. Any ideas?

parzel
  • 1

1 Answers1

0

You can get the plain HTML source by using driver.get(f"view-source:{url}"). Then get the body of the source using driver.find_element_by_tag_name('body').text

Mitchell Olislagers
  • 1,758
  • 1
  • 4
  • 10