Skip to content

Latest commit

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

项目结构

├── Readme.md
├── jingdong-crawler **使用httpclient进行原生爬虫**
│ ├── db
│ ├── jingdong-crawler.iml
│ ├── pom.xml
│ ├── src
│ └── target
└── webmagic-crawler **使用webmagic框架进行爬虫**
├── db
├── pom.xml
├── src
├── target
└── webmagic-crawler.iml

目标

  • csdn文章爬虫

  • 51Job招聘信息爬虫

  • Github用户和仓库信息爬虫

  • 京东手机数据爬虫

  • hita元数据服务爬虫

  • 剧迷TV视频网站爬虫

IDEA启动

  1. 设置idea激活的profile,指定数据库使用pg还是mysql

  1. 配置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();
      }
    • 数据库用于持久化爬取到的数据库

  2. 启动类Application选择要跑的任务,放开注释即可

publicvoidrun(String... args) throwsException {
// githubRepoProcessor.start();// jobProcessor.start();// csdnBlogPageProcessor.start();// hitaProcessor.start();
}

About

使用Java针对各大型网站的爬虫实战 🕷

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages