Commit 7b45bc9a authored by shenjunlin's avatar shenjunlin

添加超时操作

parent 10d3b829
......@@ -6,7 +6,7 @@
<version>7</version>
</parent>
<groupId>us.codecraft.duiba</groupId>
<version>0.8.4-SNAPSHOT</version>
<version>0.8.6-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<properties>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>us.codecraft.duiba</groupId>
<artifactId>webmagic-parent</artifactId>
<version>0.8.4-SNAPSHOT</version>
<version>0.8.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>us.codecraft.duiba</groupId>
<artifactId>webmagic-parent</artifactId>
<version>0.8.4-SNAPSHOT</version>
<version>0.8.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
package us.codecraft.webmagic.downloader;
import com.sun.tools.internal.xjc.reader.xmlschema.BindYellow;
import io.github.bonigarcia.wdm.ChromeDriverManager;
import io.github.bonigarcia.wdm.InternetExplorerDriverManager;
import io.github.bonigarcia.wdm.PhantomJsDriverManager;
......@@ -141,9 +140,11 @@ public class SeleniumDownloader implements Downloader, Closeable {
logger.info("downloading page " + request.getUrl());
String content = "";
try {
webDriver.manage().timeouts().pageLoadTimeout(8, TimeUnit.SECONDS);
webDriver.get(request.getUrl());
new WebDriverWait(webDriver, 10)
.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html")));
WebDriverWait webDriverWait = new WebDriverWait(webDriver, 8);
webDriverWait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html")));
WebElement webElement = webDriver.findElement(By.xpath("/html"));
content = webElement.getAttribute("outerHTML");
// Thread.sleep(sleepTime);
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>us.codecraft.duiba</groupId>
<artifactId>webmagic-parent</artifactId>
<version>0.8.4-SNAPSHOT</version>
<version>0.8.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>us.codecraft.duiba</groupId>
<artifactId>webmagic-parent</artifactId>
<version>0.8.4-SNAPSHOT</version>
<version>0.8.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>us.codecraft.duiba</groupId>
<artifactId>webmagic-parent</artifactId>
<version>0.8.4-SNAPSHOT</version>
<version>0.8.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment