Class SeleniumDownloader
java.lang.Object
us.codecraft.webmagic.downloader.AbstractDownloader
us.codecraft.webmagic.downloader.selenium.SeleniumDownloader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Downloader
使用Selenium调用浏览器进行渲染。目前仅支持chrome。
需要下载Selenium driver支持。
需要下载Selenium driver支持。
- Author:
- code4crafter@gmail.com
Date: 13-7-26
Time: 下午1:37
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor without any filed.SeleniumDownloader
(String chromeDriverPath) 新建 -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Downloads web pages and store in Page object.setSleepTime
(int sleepTime) set sleep time to wait until load successvoid
setThread
(int thread) Tell the downloader how many threads the spider used.
-
Constructor Details
-
SeleniumDownloader
新建- Parameters:
chromeDriverPath
- chromeDriverPath
-
SeleniumDownloader
public SeleniumDownloader()Constructor without any filed. Construct PhantomJS browser
-
-
Method Details
-
setSleepTime
set sleep time to wait until load success- Parameters:
sleepTime
- sleepTime- Returns:
- this
-
download
Description copied from interface:Downloader
Downloads web pages and store in Page object.- Specified by:
download
in interfaceDownloader
- Parameters:
request
- requesttask
- task- Returns:
- page
-
setThread
public void setThread(int thread) Description copied from interface:Downloader
Tell the downloader how many threads the spider used.- Specified by:
setThread
in interfaceDownloader
- Parameters:
thread
- number of threads
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-