package org.ec.downloader;

import org.ec.scheduler.Task;

import java.io.IOException;

/**
 * {@code SeleniumDownloader} is used for download the pages via AJAX rendering.
 *
 * @author dolphineor
 */
public class SeleniumDownloader implements Downloader {
    @Override
    public String download(Task task) throws IOException {
        return null;
    }
}

@@ -55,301 +55,1413 @@
 sk;%0A
-%0Aimport java.io.IOException;%0A%0A/**%0A * %7B@code SeleniumDownloader%7D is used for download the pages via AJAX rendering.%0A *%0A * @author dolphineor%0A */%0Apublic class SeleniumDownloader implements Downloader %7B%0A    @Override%0A    public String download(Task task) throws IOException %7B%0A        return null;
+import org.openqa.selenium.By;%0Aimport org.openqa.selenium.WebDriver;%0Aimport org.openqa.selenium.WebElement;%0Aimport org.openqa.selenium.chrome.ChromeDriver;%0Aimport org.openqa.selenium.remote.DesiredCapabilities;%0A%0Aimport java.io.IOException;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.concurrent.TimeUnit;%0A%0A/**%0A * %7B@code SeleniumDownloader%7D is used for download the pages via AJAX rendering.%0A *%0A * @author dolphineor%0A */%0Apublic class SeleniumDownloader implements Downloader %7B%0A    @Override%0A    public String download(Task task) throws IOException %7B%0A        Map%3CString, Object%3E contentSettings = new HashMap%3C%3E();%0A        contentSettings.put(%22images%22, 2);%0A%0A        Map%3CString, Object%3E preferences = new HashMap%3C%3E();%0A        preferences.put(%22profile.default_content_settings%22, contentSettings);%0A%0A        DesiredCapabilities caps = DesiredCapabilities.chrome();%0A        caps.setCapability(%22chrome.prefs%22, preferences);%0A        WebDriver webDriver = new ChromeDriver(caps);%0A        webDriver.get(task.getUrl());%0A        sleep(1, TimeUnit.SECONDS);%0A        WebElement webElement = webDriver.findElement(By.xpath(%22/html%22));%0A        webDriver.close();%0A        return webElement.getAttribute(%22outerHTML%22);%0A    %7D%0A%0A    private void sleep(long time, TimeUnit unit) %7B%0A        try %7B%0A            unit.sleep(time);%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D
 %0A   

Implement SeleniumDownloader