zoukankan      html  css  js  c++  java
  • 2 scrapy框架

    1、概要


    2、步骤

    1、

    ##################### settings文件:#############################
    # 头伪装
    USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0'
    
    # Obey robots.txt rules
    ROBOTSTXT_OBEY = False
    
    # 只显示print和错误信息
    LOG_LEVEL = 'ERROR'
    
    ##################### 主文件:#################################
    # 注释掉allowed_domains 
    

    3.基于观管道的持久化存储

    ############## 1.items.py #############
    class FirstBloodItem(scrapy.Item):
        # define the fields for your item here like:
        name = scrapy.Field()
        url = scrapy.Field()
    
    ############## 2.pipelines.py ##########
    class FirstBloodPipeline:
        # 专门用来接收和处理item类型对象
        def process_item(self, item, spider):
            return item
    
    ############## 3.主文件.py ###########
    from first_blood.items import FirstBloodItem
    
    ############## 4.settings.py(行) ###########
    ITEM_PIPELINES = {
       'first_blood.pipelines.FirstBloodPipeline': 300,
    }
    
    
  • 相关阅读:
    DeflateStream类
    BufferedStream类
    FileStream类
    Asp.net MVC Comet 推送
    MVC 读书笔记
    MVC部署
    MVC系统过滤器、自定义过滤器
    MVC 路由规则
    MVC 模型绑定
    边双+点双模板
  • 原文地址:https://www.cnblogs.com/shendaw/p/13455316.html
Copyright © 2011-2022 走看看