我们说的无头模式,只是在爬虫执行的时候,不再弹出浏览器的界面,只是使用浏览器的内核进行爬取,下面是示例代码:                 

        //设置本地chromedriver地址
        System.setProperty("webdriver.chrome.driver", "G:\\software\\chromedriver_win32\\chromedriver.exe");
        
        //创建无Chrome无头参数
        ChromeOptions chromeOptions=new ChromeOptions();
        chromeOptions.addArguments("-headless");
        
        //创建Drive实例
        WebDriver driver = new ChromeDriver(chromeOptions);
        

 

   

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2021-07-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
相关资源
相似解决方案