AI智能
改变未来

scrapy中shell的使用,解析shell对象


一、shell使用

shell对象

[s] Available Scrapy objects:
[s] scrapy scrapy module (contains scrapy.Request, scrapy.Selector, etc)
[s] crawler <scrapy.crawler.Crawler object at 0x000001D84A52E4E0>
[s] item {}
[s] request <GET https://www.baidu.com>
[s] response <200 https://www.baidu.com>
[s] settings <scrapy.settings.Settings object at 0x000001D84A7E91D0>
[s] spider <DefaultSpider ‘default’ at 0x1d84ac98358>
[s] Useful shortcuts:
[s] fetch(url[, redirect=True]) Fetch URL and update local objects (by default, redirects are followed)
[s] fetch(req) Fetch a scrapy.Request and update local objects
[s] shelp() Shell help (print this help)
[s] view(response) View response in a browser

1.对象作用

  • fetch(URL)

    切换到指定的url

  • fetch(req)

      req = scrapy.Requests(url)fetch(req)shelp()
  • shelp()

      打印出所有命令
  • view(response)

      直接打开response相应的网页
  • settings[\'ITEM_PIPELINES\']

      找出settings里面ITEM_PIPELINES的值
  • 赞(0) 打赏
    未经允许不得转载:爱站程序员基地 » scrapy中shell的使用,解析shell对象