bosondata / chrome-prerender

Render JavaScript-rendered page as HTML/PDF/mhtml/png/jpeg using Headless Chrome
MIT License
165 stars 20 forks source link

option to disable images #20

Closed Nyoroon closed 6 years ago

Nyoroon commented 7 years ago

It's possible to have option to disable loading images when rendering? In original prerender image loading was disabled https://github.com/prerender/prerender/blob/c3a83d6ba001cac6e2dc22cacab6b7d510835e36/lib/server.js#L72 It's controlled by chrome headless CLI options or doable via api?

messense commented 7 years ago

Didn't find any CLI options. http://peter.sh/experiments/chromium-command-line-switches/

The only API can do that is Network.setBlockedURLs, but I am not sure whether it is able to set blocked url to https?://**.jpg. Even if it can, images without extension can still be loaded.

Nyoroon commented 7 years ago

hm, but selenium is doing that somehow https://stackoverflow.com/a/31581387

messense commented 7 years ago

You might be able to do that with --user-data-dir option set and add a Preferences file in the right directory in user data dir then start chrome.

https://www.chromium.org/administrators/configuring-other-preferences

messense commented 7 years ago

I think that's how chromedriver do that which applies to selenium.

https://github.com/bayandin/chromedriver/blob/master/chrome_launcher.cc#L804

messense commented 6 years ago

Fixed in https://github.com/bosondata/chrome-prerender/commit/3ab22d4efa0a012c015d98f2c9e1d6569a8e73d9