Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件下载器优化 #33

Open
nonacosa opened this issue May 12, 2017 · 3 comments
Open

文件下载器优化 #33

nonacosa opened this issue May 12, 2017 · 3 comments
Labels

Comments

@nonacosa
Copy link
Collaborator

讨论请求出带抓取文件队列后的下载问题。

@nonacosa
Copy link
Collaborator Author

nonacosa commented May 12, 2017

@wangtonghe

.setHandler(new FileDownloadHandler("/Users/pg/Desktop"))
                .setHandler(new ConsoleHandler())

down文件方法写在process里更易懂,
.setHandler(new ConsoleHandler()) 这行的作用是什么,能不能更简化一点

@wangtonghe
Copy link
Member

new ConsoleHandler() 设置处理结果的处理器,这个是设置在控制台输出

@wangtonghe
Copy link
Member

可以设置多个处理器。比如

.setHandler(new JsonFileHandler(PATH,FILENAME))
     .setHandler(new ConsoleHandler())

会将爬取结果打印到控制台、保存在json文件中。
自感觉文件下载也是处理结果的一种方式,若用户在爬取过程中想下载某些文件,在这加一个文件结果处理器,然后在process中把文件url放入结果集即可。这样和普通的爬取处理一致。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants