public abstract class BaseDownloader extends Object implements Downloader
Constructor and Description |
---|
BaseDownloader(String driverPath)
构造函数
必须传入浏览器驱动文件geckodriver所在地址的路径 geckodriver文件的下载路径为 https://github.com/mozilla/geckodriver/releases 请根据运行环境的信息配置好此参数 |
Modifier and Type | Method and Description |
---|---|
void |
close()
关闭下载器以释放资源
|
Page |
down(Request request)
下载对应的请求资源
|
protected abstract Page |
down(org.openqa.selenium.WebDriver driver,
Request request)
执行真正的下载操作
|
protected abstract void |
preHandle(Request request,
org.openqa.selenium.WebDriver driver)
正式下载前的前置操作
可以在此操作中修改 Web浏览器对象,进行属性设置 |
public BaseDownloader(String driverPath) throws com.yishuifengxiao.common.tool.exception.ServiceException
driverPath
- 浏览器驱动文件geckodriver的地址com.yishuifengxiao.common.tool.exception.ServiceException
- 创建浏览器对象时出现的问题protected abstract void preHandle(Request request, org.openqa.selenium.WebDriver driver)
request
- 当前的下载请求任务driver
- Web浏览器对象protected abstract Page down(org.openqa.selenium.WebDriver driver, Request request) throws com.yishuifengxiao.common.tool.exception.ServiceException
driver
- Web浏览器对象request
- 当前的下载请求任务com.yishuifengxiao.common.tool.exception.ServiceException
public Page down(Request request) throws com.yishuifengxiao.common.tool.exception.ServiceException
Downloader
down
in interface Downloader
request
- 当前的下载请求com.yishuifengxiao.common.tool.exception.ServiceException
public void close()
Downloader
close
in interface Downloader
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.