How to load only html from web pages in selenium

How to load only html from web pages in selenium?

I only need the html of the requested page without css and javascript.

+3
javascript html css selenium selenium-webdriver


source to share


1 answer


If you need selenium for web scraping, strictly speaking, you will still need javascript and css files, as these can significantly affect page loading and rendering. For example, multiple parts of the page can be loaded with additional ajax calls, or inserted through custom JavaScript logic.

Also, if you only want the HTML portion of the page, why would you need a real browser?



If you still want to prevent js and css files from being loaded, you can adjust specific permissions in Firefox using settings FirefoxProfile

, see

  • No need to load images and CSS for rendering in Firefox in Selenium WebDriver tests with Python
  • FirefoxDriver: how to disable javascript, css and make sendKeys type instantly?
+2


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics