python scrapy 爬虫框架安装问题总结一

0. workon scrapy_py3    (进入Python虚拟环境)

1. cd指定目录

2. scrapy startproject AdilCrawler

3. cd 到项目AdilCrawler下,执行scrapy genspider thousandPic www.58pic.com

4. cd spiders文件夹中,  编辑文件thousandPic.py。

5. 启动爬虫 scrapy crawl thousandPic (如果报错  builtins.ModuleNotFoundError: No module named '_sqlite3')

处理方法:

> 下载 sqlite-autoconf-3240000.tar.gz, 地址:https://www.sqlite.org/download.html

> 安装  ./configure --prefix=/usr/local/sqlite  && make && sudo make install

> 下载Python-3.6.10.tar, 如果有python3的tar包可以不需要下载了,建议使用tar包编译安装。

> cd Python-3.6.10

> vi setup.py  添加如图两句。

> python scrapy 爬虫框架安装问题总结一_第1张图片

> 重新编译安装python包   ./configure --enable-loadable-sqlite-extensions && make && sudo make install

> 在Python虚拟环境scrapy_py3中,如图,执行python -> import sqlite3 不报错,说明解决问题了。

> 启动爬虫 scrapy crawl thousandPic    即可成功。

参考博客:https://www.jianshu.com/p/dd4532457b9f

 

 

你可能感兴趣的:(python爬虫)