在过去的几年里,我一直在这个网站上爬行。突然,“谷歌隐形重新验证码”在一个网站上实现了。
在本地机器(窗口)中,我得到了html内容,但当我在linux服务器上运行时,出现了“超时错误”。我尝试了5-10分钟的等待时间,但仍然不起作用。
linux debain(cenots 7)
chrome版本:92.0.4515.107
//String chromeDriverPath = "D:/CodeAxis/ChromeDriver/chromedriver.exe";// local machine driver path
String chromeDriverPath = "/root/TestCaseChromeDriver/DriverPath/chromedriver";// linux driver server path
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless","--window-size=1920,1200","--ignore-certificate-errors");
options.addArguments("start-maximized");
options.addArguments("enable-automation");
options.addArguments("--no-sandbox");
options.addArguments("--disable-infobars");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--disable-browser-side-navigation");
options.addArguments("--disable-gpu");
options.addArguments("--disable-features=VizDisplayCompositor");
options.addArguments("--disable-web-security");
options.addArguments("user-agent=Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 640 XL LTE) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Mobile Safari/537.36 Edge/12.10166")
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);//if takes this much time to load all components
driver.manage().timeouts().pageLoadTimeout(140, TimeUnit.SECONDS); //Time allowed to load the page if not loaded
driver.get("<SITE_PATH>");
driver.getCurrentUrl();
System.out.println(driver.getPageSource());
driver.quit();
暂无答案!
目前还没有任何答案,快来回答吧!