解决大家关于Ubuntu16.04下的ipython的问题

    xiaoxiao2021-12-08  5

    前提:本人用的PC系统是Linux下的Ubuntu16.04系统

    简介:首先ipython是Python的交互式的shell,比默认的Python shell好用,支持自动补全,自动缩进,支持bash shell命令。

        一:安装

      第一种方法是ipython源码安装:https://pypi.python.org/pypi/ipython

      第二种方法是命令行的安装:sudo apt-get install ipython

    这里主要讲解scrapy框架下的使用  我们可以去解析网页

    首先运行shell:scrapy shell<url>      url是你想去的url

    我们在利用path这个模块的时候来搜索的时候,例如::hxs.path('//title')来获取上面说的那个网页的标题的时候(或者是来获取网页的body:hxs.path('//body'))

    但是你会遇到一个问题,如下:

    NameError: name 'hxs' isd not define

    怎么解决呢?

    解决的方法是:sel.xpath('//title')

    或者是你可以通过以下的方法来解决,也是一种不错的方法解析网页里你想要的东西

    有关这块我们翻墙后可以采纳stackoverflow里的文章

    url:http://stackoverflow.com/questions/25955289/nameerror-name-hxs-is-not-defined-when-using-scrapy

    请关注本博,后续!!!

    转载请注明原文地址: https://ju.6miu.com/read-681677.html

    最新回复(0)