Class SeleniumDownloader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, us.codecraft.webmagic.downloader.Downloader

    public class SeleniumDownloader
    extends us.codecraft.webmagic.downloader.AbstractDownloader
    implements java.io.Closeable
    使用Selenium调用浏览器进行渲染。目前仅支持chrome。
    需要下载Selenium driver支持。
    Author:
    code4crafter@gmail.com
    Date: 13-7-26
    Time: 下午1:37
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      us.codecraft.webmagic.Page download​(us.codecraft.webmagic.Request request, us.codecraft.webmagic.Task task)  
      SeleniumDownloader setSleepTime​(int sleepTime)
      set sleep time to wait until load success
      void setThread​(int thread)  
      • Methods inherited from class us.codecraft.webmagic.downloader.AbstractDownloader

        download, download, onError, onError, onError, onSuccess, onSuccess, onSuccess
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SeleniumDownloader

        public SeleniumDownloader​(java.lang.String chromeDriverPath)
        新建
        Parameters:
        chromeDriverPath - chromeDriverPath
      • SeleniumDownloader

        public SeleniumDownloader()
        Constructor without any filed. Construct PhantomJS browser
    • Method Detail

      • setSleepTime

        public SeleniumDownloader setSleepTime​(int sleepTime)
        set sleep time to wait until load success
        Parameters:
        sleepTime - sleepTime
        Returns:
        this
      • download

        public us.codecraft.webmagic.Page download​(us.codecraft.webmagic.Request request,
                                                   us.codecraft.webmagic.Task task)
        Specified by:
        download in interface us.codecraft.webmagic.downloader.Downloader
      • setThread

        public void setThread​(int thread)
        Specified by:
        setThread in interface us.codecraft.webmagic.downloader.Downloader
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException