├── Readme.md
├── jingdong-crawler **使用httpclient进行原生爬虫**
│ ├── db
│ ├── jingdong-crawler.iml
│ ├── pom.xml
│ ├── src
│ └── target
└── webmagic-crawler **使用webmagic框架进行爬虫**
├── db
├── pom.xml
├── src
├── target
└── webmagic-crawler.iml
- 设置idea激活的profile,指定数据库使用pg还是mysql
配置redis和选择的数据库连接
redis用于分布式爬虫时记录已爬的队列和爬过的队列
在jedis中配置即可。
publicvoidstart() { Spider.create(newGithubRepoProcessor()) // 设置download解决官方webMagic无法访问部分ssl网站问题 .setDownloader(newHttpClientDownloader()) .addUrl("https://github.com/huzekang/") .setScheduler(newRedisScheduler(newJedisPool("127.0.0.1",6379))) .setPipelines(Lists.newArrayList(githubRepoJPAPipeline,githubUserJPAPipeline)) .thread(8) .runAsync(); }
数据库用于持久化爬取到的数据库
启动类Application选择要跑的任务,放开注释即可
publicvoidrun(String... args) throwsException {
// githubRepoProcessor.start();// jobProcessor.start();// csdnBlogPageProcessor.start();// hitaProcessor.start();
}



