Intelij idea 集成scrapy开发环境
来源:互联网 发布:网络机柜的作用 编辑:程序博客网 时间:2024/06/05 17:03
以MacOs sierra0.12.6 为例
1.安装Intelij idea
下载地址 https://www.jetbrains.com/idea/download/#section=mac
2.安装idea 支持 python 开发的插件
Preferences -> Plugins
3.mac 神器homebrew(已经安装好pip的同学,这一步请忽略)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
4.安装配置pip
brew install pip
安装pip之后最重要的配置就是配置pip的源,什么是源呢。。。。
就是各种插件的下载地址啦
mkdir ~/.pipvi ~/.pip/pip.conf
在pip.conf文件填入下列配置保存就好了
[global]index-url = https://pypi.douban.com/simple
楼主这里用的是豆瓣的源
很多文章里面写的index-url = http://pypi.douban.com/simple,这是不对的,现在各大网站都换成了https,哪还有http的,不够安全。
国内的源还有
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/
5.安装Scrapy
sudo pip install Scrapy --upgrade --ignore-installed six
注意(大坑在此)
后面添加的参数一定要加上–upgrade –ignore-installed six
因为mac自己本身就已经安装了six包,但是因为系统安全的原因,这个包的权限非常高,sudo都不能执行更新,如果执行pip install Scrapy不忽略six包就会报错。
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version.
6.idea和Scrapy结合
创建一个Scrapy项目,如果对Scrapy项目不熟悉的小伙伴可以参看Scrapy的文档https://doc.scrapy.org/en/0.16/intro/tutorial.html
这里我们就使用文档里的介绍来创建一个最简单
scrapy startproject tutorial
使用idea打开tutorial项目
根据官网文档,我们创建一个最简单的爬虫
import scrapy;class QuotesSpider(scrapy.Spider): name = "quotes" def start_requests(self): urls = [ 'http://quotes.toscrape.com/page/1/', 'http://quotes.toscrape.com/page/2/', ] for url in urls: yield scrapy.Request(url=url, callback=self.parse) def parse(self, response): page = response.url.split("/")[-2] filename = 'quotes-%s.html' % page with open(filename, 'wb') as f: f.write(response.body) self.log('Saved file %s' % filename)
然后在右上角配置运行环境 Edit Configurations…
Script选择项目的__init__.py
文件
然后修改__init__.py
文件
from scrapy import cmdlinecmdline.execute("scrapy crawl quotes".split());
这样idea就跟Scrapy完美结合了,运行,断点debug,代码分析不在话下。这些功能都在右上角这么些个按钮了。各位同学自己慢慢去试吧。
- Intelij idea 集成scrapy开发环境
- InteliJ IDEA + Genymotion搭建Android开发环境(win 7)
- intelij Idea的scala环境配置
- ubuntu 14.04 java开发环境搭建 jdk 以及 inteliJ IDEA安装
- ubuntu 14.04 java开发环境搭建 jdk 以及 inteliJ IDEA安装
- InteliJ IDEA
- intelij idea导入开发code样式主题
- Intellij IDEA集成开发环境 安装破解
- IntelliJ IDEA 智能集成开发环境使用指南
- Intelij Idea 快捷键
- Intelij IDEA 常用快捷键
- Intelij Idea常用插件
- [Erlang]InteliJ IDEA使用方法
- intelij Idea使用
- InteliJ IDEA使用
- intelij idea 注册码
- InteliJ IDEA使用文档
- Intelij IDEA 常用快捷键
- Spark Partition
- hdu2191(多重背包的二进制和普通做法)
- Codeforces 830D [DP]
- Python中json数据转换问题
- Java知识:TreeSet详解
- Intelij idea 集成scrapy开发环境
- tomcat 启动后 闪退 (环境配置都是对的TT)
- 专注要事、把手弄脏、高效优雅是对抗规模化焦虑的好办法--读Getting Real(达成现实)和 Rework(重塑工作)
- 1.6 c++_指针
- python中threading模块详解
- 图解http(返回结果的HTTP状态码四 与http协作的web服务器五 http首部六)
- 关于路由器出现问题记录
- Fred 7.0.0 光线追迹软件_USB加密锁,全模块运行稳定版\
- VMware WorkStation的三种网络连接方式