zoukankan      html  css  js  c++  java
  • python爬虫入门(6)-Scrapy基本使用

    源码:链接:http://pan.baidu.com/s/1dEK82hb 密码:9flo
     
    创建项目                                 scrapy startproject tutorial
    爬取                                         scrapy crawl dmoz
    爬取并保存为json格式           scrapy crawl dmoz -o items.json -t json

    scrapy shell "网址/资源"
    载入之后将能得到response的回应
    response.body
    response.headers
    >>>response.xpath('//title')
    >>>response.xpath('//title/text()').extract()
     
     

    编辑Item:
        # -*- coding: utf-8 -*-
        # Define here the models for your scraped items
        #
        # See documentation in:
        # http://doc.scrapy.org/en/latest/topics/items.html
        import scrapy
        class DmozItem(scrapy.Item):
            # define the fields for your item here like:
            # name = scrapy.Field()
            title = scrapy.Field()
            link = scrapy.Field()
            desc = scrapy.Field()
    
     
    编辑蜘蛛:
     
     
    爬取并保存为json格式
    至此,根目录下会多出一个json文件
     

     





  • 相关阅读:
    Angular
    Angular
    Angular
    Angular
    Angular
    Angular
    Angular
    springsecurity 源码解读 之 RememberMeAuthenticationFilter
    springsecurity 源码解读之 AnonymousAuthenticationFilter
    springsecurity 源码解读之 SecurityContext
  • 原文地址:https://www.cnblogs.com/tcheng/p/6888939.html
Copyright © 2011-2022 走看看