首页 > IPython shell中解析HTML的 hxs 变量被提示“name 'hxs' is not defined”?

IPython shell中解析HTML的 hxs 变量被提示“name 'hxs' is not defined”?

IPython 安装好后,终端已经有语法高亮提示,并且response.body和response.headers都有返回值。
当我在In1:后面输入
hxs.path('//title')
回车
提示name 'hxs' is not defined。

查资料,上面说‘Shell也实例化了两种selectors,一个是解析HTML的 hxs 变量,一个是解析 XML 的 xxs 变量。’

难道没有实例化成功?

如何解决?求教。

资料来自
http://doc.scrapy.org/en/latest/intro/tutorial.html#intro-tutorial

http://www.cnblogs.com/txw1958/archive/2012/07/16/scrapy-tutorial.html

-----------------可能解决---------------------------
selector实例化后默认sel,用什么版本一定要看什么版本的文档,我这个版本用的是0.20.2,所以一定要看0.20.2的document


查看了一下,现在0.24中的scrapy shell中,hxs已经被取代了,取而代之的是sel对象,lz可以看下面的连接
https://scrapy-chs.readthedocs.org/zh_CN/0.24/topics/shell.html
但是我在使用的时候,发现,sel对象也被取代了,给出的提示信息是:
ScrapyDeprecationWarning: "sel" shortcut is deprecated. Use "response.xpath()", "response.css()" or "response.selector" instead
好吧,用response.xpath没问题

【热门文章】
【热门文章】