PhantomJS 1.8 with Selenium on python. How to block images?

前端 未结 2 809
不知归路
不知归路 2021-02-20 00:57

Is there a way to configure PhantomJS webdriver on Selenium to do not load images? I know if I use phantomjs directly, I can start it with --load-images=no and it w

相关标签:
2条回答
  • 2021-02-20 01:05

    Why are you not trying webdriver.PhantomJS(service_args=['--load-images=no']) ?

    0 讨论(0)
  • 2021-02-20 01:27

    EDIT: passing arguments is exposed, see the same answer mentioned below for how to do it

    Passing arguments to phantomjs is not currently exposed with selenium's webdriver's init ... I have worked around that by monkey patching the PhantomJS executer. Check that answer changing service_args to the following:

    service_args += [
        '--load-images=no',
    ]
    

    You could also opt to start the phantomjs server yourself, and just use the following call to point to an already running phantomjs at port 8080

    # init the webdriver
    self.driver = webdriver.PhantomJS(port=8080)
    
    0 讨论(0)
提交回复
热议问题