Can I load New Page without images

Hi,

I have run t task browser library 12.30 inside a container as on-demand cloud instance. It works great, it is cheap. The only thing that costs a little seems to be the traffic when the tasks calls other websites.

So I wonder, if I can somehow manage to:

  • Open a Page
  • and block downloading images in that page (I am only interested in the source code or text anyway)
    in order to reduce traffic.

I do not even know, if that is technically possible. I found an indiciation for playwright on GitHub about routes: [Question]: How to disable image loading? · Issue #955 · microsoft/playwright-python · GitHub

Regards,
Markus

Hi Markus,

I do not have a solution at hand but found that chrome offers two different options to prevent image loading:
https://www.groovypost.com/howto/disable-chrome-site-specific-image-loading/
https://www.wikihow.com/Disable-Images-in-Google-Chrome
At first glance, i could not figure out how to make this configurable by command line / settings. But it is perhaps a good starting point…
Regards,
Simon

1 Like

Hi Markus,

There is always the brute force way, disable dns in your container, then put the site(s) you want to test in the host file. If there is is no way to resolve the address of other sites there is no way to download the images. (this is basically how ad blockers work)

Dave.

1 Like

Hi Dave!
Chrome has a host-mapping command line option - command line - Host-rules google chrome, adding configuration - Stack Overflow
So you can, for example, set all domain names of sites hosting images to localhost.
You can also solve your problem outside of RF, by tuning firewall rules to drop transfer of image files from sites you want.

1 Like

Hi Lev,

That sounds like a great solution, can you figure out if that can be passed to New Browser so Markus can use it?

Dave.

AFAIK New Browser has a args argument. It’s a list of command-line options.
Just need to add to that list something like this:
"--host-resolver-rules=", "MAP * 127.0.0.1, EXCLUDE *my.cool.site*"
That way, everything that not from my.cool.site domain will be blocked