public void test1(){ //System.setProperty("webdriver.firefox.bin", "D:/software/Mozilla Firefox/firefox.exe"); String path = demo1.class.getClassLoader().getResource("").getPath()+"phantomjs-2.1.1-windows\\bin\\phantomjs.exe"; System.setProperty("phantomjs.binary.path", path); //System.setProperty("webdriver.gecko.driver", "D:/software/geckodriver.exe"); WebDriver driver = new PhantomJSDriver(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); //System.out.println("session id : "+ ((FirefoxDriver) driver).getSessionId()); //driver.navigate().to("http://127.0.0.1:8000"); driver.get("http://127.0.0.1:8000"); // WebElement element = driver.findElement(By.xpath("input")); //WebElement element = driver.findElement(By.name("submit")); //element.sendKeys("abc"); //element.submit(); System.out.print(driver.getPageSource()); driver.close(); }
java方式selenium+phantomjs动态爬虫入门案例
最新推荐文章于 2024-07-09 13:58:47 发布