|
|
|
@ -1,15 +1,5 @@
|
|
|
|
|
package us.codecraft.webmagic.downloader.selenium;
|
|
|
|
|
|
|
|
|
|
import org.openqa.selenium.WebDriver;
|
|
|
|
|
import org.openqa.selenium.chrome.ChromeDriver;
|
|
|
|
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
|
|
|
|
import org.openqa.selenium.phantomjs.PhantomJSDriver;
|
|
|
|
|
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
|
|
|
|
|
import org.openqa.selenium.remote.DesiredCapabilities;
|
|
|
|
|
import org.openqa.selenium.remote.RemoteWebDriver;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.io.FileReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
@ -22,6 +12,18 @@ import java.util.concurrent.BlockingDeque;
|
|
|
|
|
import java.util.concurrent.LinkedBlockingDeque;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
|
import org.openqa.selenium.WebDriver;
|
|
|
|
|
import org.openqa.selenium.chrome.ChromeDriver;
|
|
|
|
|
import org.openqa.selenium.chrome.ChromeOptions;
|
|
|
|
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
|
|
|
|
import org.openqa.selenium.firefox.FirefoxOptions;
|
|
|
|
|
import org.openqa.selenium.phantomjs.PhantomJSDriver;
|
|
|
|
|
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
|
|
|
|
|
import org.openqa.selenium.remote.DesiredCapabilities;
|
|
|
|
|
import org.openqa.selenium.remote.RemoteWebDriver;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author code4crafter@gmail.com <br>
|
|
|
|
|
* Date: 13-7-26 <br>
|
|
|
|
@ -73,7 +75,6 @@ class WebDriverPool {
|
|
|
|
|
|
|
|
|
|
// Prepare capabilities
|
|
|
|
|
sCaps = new DesiredCapabilities();
|
|
|
|
|
sCaps.setJavascriptEnabled(true);
|
|
|
|
|
sCaps.setCapability("takesScreenshot", false);
|
|
|
|
|
|
|
|
|
|
String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
|
|
|
|
@ -134,9 +135,9 @@ class WebDriverPool {
|
|
|
|
|
sCaps.setBrowserName("phantomjs");
|
|
|
|
|
mDriver = new RemoteWebDriver(new URL(driver), sCaps);
|
|
|
|
|
} else if (driver.equals(DRIVER_FIREFOX)) {
|
|
|
|
|
mDriver = new FirefoxDriver(sCaps);
|
|
|
|
|
mDriver = new FirefoxDriver(new FirefoxOptions(sCaps));
|
|
|
|
|
} else if (driver.equals(DRIVER_CHROME)) {
|
|
|
|
|
mDriver = new ChromeDriver(sCaps);
|
|
|
|
|
mDriver = new ChromeDriver(new ChromeOptions().merge(sCaps));
|
|
|
|
|
} else if (driver.equals(DRIVER_PHANTOMJS)) {
|
|
|
|
|
mDriver = new PhantomJSDriver(sCaps);
|
|
|
|
|
}
|
|
|
|
|