最近在学 python 爬虫,所以写了个脚本抓取 mm131.net 练练手。
- 使用了爬虫框架 scrapy
- user-agent 使用了fake-useragent
- 使用 python 3.7
scrapymm131 项目主目录
├── scrapymm131 爬虫主目录
│ └── spiders 爬虫脚本目录
├── CHANGELOG.md 变更日志
└── TODO.md 计划功能
确保已经安装了 scrapy 库及相关依赖
$ pip install scrapy
确保已经安装了 fake-useragent
$ pip install fake-useragent
因为使用了 peewee 和 MySQL,确保这两个包已经安装
$ pip install pymysql
$ pip install peewee
将脚本 clone 到本地,
在 settings.py 中设置数据库相关信息,
进入到脚本目录启动爬虫
$ scrapy crawl mm131