1. scrapy shell

是scrapy包的一个很好的交互性工具,目前我使用它主要用于验证xpath选择的结果。安装好了scrapy之后,就能够直接在cmd上操作scrapy shell了。

具体的解释参考官网

https://docs.scrapy.org/en/latest/topics/shell.html

2. ipython

在官网推荐使用ipython来跑scrapy shell,于是我尝试安装。因为之前我的python环境都是通过conda配置的(参看前一篇),通过conda安装ipython很方便

conda install -c conda-forge ipython

然后整个ipython的包就会下载下来,因为都是编译好的,没有了烦人的编译失败的过程了。

3. 运行ipython和在ipython上运行scrapy shell

在当前的cmd运行框中,因为已经配置了系统环境,是可以直接运行python包的,所以直接在cmd运行框中敲入ipython就会进入到ipython的运行框,跟系统标准的cmd差不多,但是功能更丰富,色彩更丰富,布局也能好。

但是当我直接在这上面敲scrapy shell命令,但是一直说没有此命令,失败。在这里卡住了。

后来通过仔细阅读scrapy shell的说明

If you have IPython installed, the Scrapy shell will use it (instead of the standard Python console). 

意思就是scrapy shell会自己去找ipython的运行框。

于是直接在cmd的标准运行框中输入scrapy shell <url>,返回的结果直接调用到ipython的运行框了。

例子

scrapy shell “http://scrapy.org” --nolog

注意这里的双引号,之前我遵从官网的例子,写了单引号,一直返回invalid hostname,改为双引号之后,才解决问题。

English Version

1. scrapy shell

is a good interactive tool that Scrapy provided. Currently I use it to validate xpath result before I write scripts. After installed Scrapy, the Scrapy shell can be used from CMD.

For detail specification, please refer to below

https://docs.scrapy.org/en/latest/topics/shell.html

2. ipython

Scrapy recommand iPython as user interface to run Scrapy Shell, so I try to install iPython, which is also a Python extention package. As my Python env is from Conda, it's very easy to install iPython (how to install package in Conda env). Just run below command.

conda install -c conda-forge ipython

3. Run iPython, and run Scrapy Shell on iPython

How to run iPython? just key in "iPython" in your CMD prompt that has included Python path in system env path. A python-like user interface will appear, but more colorful, more functional and the layout is clearer.

So when I was in iPython interface, I try to key in "scrapy shell", but failed to work. The prompt said the command is not exist.

I was confused, and stuck here. However I found below note when I read scrapy shell specification again,

If you have IPython installed, the Scrapy shell will use it (instead of the standard Python console). 

So I just key in "scrapy shell <url>" in original windows CMD prompt, the scrapy shell automatically run at iPython interface

example

scrapy shell “http://scrapy.org” --nolog

Note, I use double quotation mark " " instead of single quotation mark ' ' which is used in scrapy shell specification example.

it returns "invalid hostname" when I use single quotation mark.  

安装ipython,使用scrapy shell来验证xpath选择的结果 | How to install iPython and how does it work with Scrapy Shell的更多相关文章

  1. Scrapy框架中的xpath选择

    不同于我们普通爬虫获取xpath,scrapy获得xpath对象获取他的值语法 一.xpath对象获取值 xpath对象..extract() 二.Scrapy框架独有的xpath取值方式 利用hre ...

  2. 爬虫系列3:scrapy技术进阶(xpath、rules、shell等)

    本文主要介绍与scrapy应用紧密相关的关键技术,不求很深入,但求能够提取要点.内容包括: 1.xpath选择器:选择页面中想要的内容 2.rules规则:定义爬虫要爬取的域 3.scrapy she ...

  3. Ant安装、环境变量配置及验证

    一.安装ant 到官方主页http://ant.apache.org下载新版(目前为Ant1.8.1)的ant,得到的是一个apache-ant-1.8.1-bin.zip的压缩包.将其解压到你的硬盘 ...

  4. Scrapy:学习笔记(1)——XPath

    Scrapy:学习笔记(1)——XPath 1.快速开始 XPath是一种可以快速在HTML文档中选择并抽取元素.属性和文本的方法. 在Chrome,打开开发者工具,可以使用$x工具函数来使用XPat ...

  5. 【转】ANT安装、环境变量配置及验证

    http://www.cnblogs.com/yuzhongwusan/archive/2013/03/26/2982411.html Posted on 2013-03-26 14:01 yuzho ...

  6. 在Scrapy中如何利用Xpath选择器从HTML中提取目标信息(两种方式)

    前一阵子我们介绍了如何启动Scrapy项目以及关于Scrapy爬虫的一些小技巧介绍,没来得及上车的小伙伴可以戳这些文章: 手把手教你如何新建scrapy爬虫框架的第一个项目(上) 手把手教你如何新建s ...

  7. 用XPath定位Web页面元素时,如何快速验证XPath语句是否正确?

    在使用Selenium做Web UI自动化测试的过程中,XPath是一种定位页面元素的常用方式.然而,面对某些元素的XPath路径过于复杂,我们想快速验证拼凑的Xpath语句是否正确时,该怎么办呢?这 ...

  8. 推荐一个pycharm验证xpath表达式的插件XPathView +​ XSLT

    使用Appium进行自动化测试,使用xpath元素定位,想验证xpath定位是否正确,可以使用在线的xpath验证网站,也可以使用这次推荐的插件XPathView +​ XSLT.

  9. ubuntu 安装 google Gtest [转]有效性待验证

    最近在做一些东西,用过gtest,废话少说,现讲其再ubuntu上安装的 方法贴出来,以供朋友们参考: 安装gtest分三步: 1.安装源代码 在ubuntu的桌面上,右键选择打开终端,在终端中输入如 ...

随机推荐

  1. 微信支付 chooseWXPay:fail

    本来以为解决了微信支付get_brand_wcpay_request:faill这个问题后就万事大吉了,结果又迈入了另一个坑... 问题原因: 1.生成签名的时间戳参数名timestamp的s大小写问 ...

  2. Oracle RAC环境下定位并杀掉最终阻塞的会话

    实验环境:Oracle RAC 11.2.0.4 (2节点) 1.模拟故障:会话被级联阻塞 2.常规方法:梳理找出最终阻塞会话 3.改进方法:立即找出最终阻塞会话 之前其实也写过一篇相关文章: 如何定 ...

  3. python flask框架 tempates 模版的使用

    在py文件同级下 建立templates文件夹,再文件夹中编写html文件 1 向模版中传递参数: ''' 1 向模板传送 参数 ''' @app.route('/') def index(): na ...

  4. Frame

    Frame意为框架,是在屏幕上的一个矩形区域. Frame主要作为其他组件的框架基础,或为其他组件提供间距补充. 何时使用Frame组件呢? Frame组件主要用于在复杂的布局中奖其他组件分组,也用于 ...

  5. django 开发忘记密码通过邮箱找回功能

    一.流程分析: 1.点击忘记密码====>forget.html页面,输入邮箱和验证码,发送验证链接网址的邮件====>发送成功,跳到send_success.html提示 2.到邮箱里找 ...

  6. iframe 里的高度自适应

    由于公司里的很多东西都要用到iframe 导致我不得不各种百度 首先是自适应高度 // document.domain = "caibaojian.com"; function s ...

  7. SQL Server 查询性能优化——创建索引原则(二)

    三:索引的建立原则 一般来说,建立索引要看数据使用的场景,换句话来说哪些访问数据的SQL语句是常用的,而这些语句是否因为缺少索引(也有可能是索引过多)变的效率低下.但绝不是所有的SQL语句都要建立索引 ...

  8. 我常用的css基础

    mkdir 创建文件夹touch 创建文件mode:'history' ----------------------------------------------------------去除# di ...

  9. HTML笔记05------AJAX

    AJAX初探01 AJAX概念 概念:即"Asynchronous JavaScript And XML" 通过在后台与服务器进行少量数据交换,AJAX可以使网页实现异步更新.这意 ...

  10. [LeetCode] Dota2 Senate 刀塔二参议院

    In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of ...