pycharm下虚拟环境执行并调试scrapy爬虫程序

虚拟环境virtualenv安装

参考我的上一篇文章windows下隔离python环境

配置scrapy环境

分别pip install Zope.Interface、Twisted、w3lib、lxml、pyOpenSSL、Scrapy
具体详情不再讲述
请参考
Scrapy安装、爬虫入门教程、爬虫实例(豆瓣电影爬虫)
Scrapy 1.0 文档

新建爬虫项目,pycharm运行

我的项目名称为RadioCrawl
文件夹为

《pycharm下虚拟环境执行并调试scrapy爬虫程序》 Paste_Image.png

新建main.py

cmdline.execute("scrapy crawl playlist".split())```
表示用命令行的方式执行我的名为playlist的爬虫程序
用pycharm打开项目

![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1908836-180a83828164cdac.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
#####打开Edit Configurations

![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1908836-896914d8ad57def6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
#####调试
可以在其他代码中设置断点,debug运行

![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1908836-80d3f622ca69e5f1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1908836-af33ca442139bc1a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
点赞