【发布时间】:2013-11-16 21:10:17
【问题描述】:
我从你们那里得到了很多帮助,我真的很高兴。已经通过了这些聚会,
web page source downloaded through Jsoup is not equal to the actual web page source
How to download a Web page source using Selenium
现在我终于来到了最后一次聚会(希望如此)
在运行 selenium 测试用例时,像这样,
WebDriver driver = new FirefoxDriver();
FluentWebDriver fwd = new FluentWebDriver(driver);
driver.manage().timeouts().implicitlyWait(5L, TimeUnit.SECONDS);
driver.get("http://www.justdial.com/Bangalore/Tape-Dealers-%3Cnear%3E-Bangalore-City-Railway-Station/ct-12976/page-5");
String res = driver.getPageSource();
它打开网络浏览器并开始下载页面中的所有图像,并导致从我的 java 程序下载源代码的延迟。在这种情况下如何避免打开我的浏览器?我只想要页面源和没有图形内容。因此也避免延误......请帮助!提前致谢!!
【问题讨论】:
-
您想要一个无头驱动程序。您可以使用 HTMLUnit 驱动程序或 PhantomDriver。