• 查询车系特定口碑信息


    特定车系口碑信息(智能tag的文案) 

    require 'JSON'
    ids = [4370,3429,4043]
    
    urltemp = "http://k.api.autohome.com.cn/api/Semantic/LoadSeriesPRCType?_appid=advert&typekey=-1&year=1&seriesId="
    ids.each do  |id|
        requrl =  urltemp + id.to_s  
        result =`curl  "#{requrl}"`
        obj  =  JSON.parse (result)
        puts "-------车系#{id}口碑------------"
        if obj["result"] && obj["result"] ["DimSeriesPRCTypes"] 
             obj["result"] ["DimSeriesPRCTypes"].each  do  |prctype |
                   if prctype["TypeKey"] == 1 
                       prctype["Summary"].each do |sum|
                           puts sum["Combination"] 
                       end 
                   else 
                       next
                   end 
             end  
         end 
    end        
    

      

    忘记了这段代码,0905又写了一遍,放在开发机器执行即可输出 

    require 'json'
    result =`curl "http://k.api.autohome.com.cn/api/Semantic/LoadSeriesPRCType?_appid=advert&typekey=-1&year=1&seriesId=4652"`
    
    puts "--------------所有评价----------------------------"
    obj = JSON.parse(result)
    ls = obj['result']['DimSeriesPRCTypes'].length
    puts  "len is  #{ls }"
    
    types = obj['result']['DimSeriesPRCTypes']
    
    dict = []
    types.each_with_index do | obj ,k|
      if  obj["Summary"] !=nil
         sm =  obj["Summary"]
         sm.each do |s|
            puts s["Combination"]
            if   s["TypeKey"] == 1
                    dict <<   s["Combination"]
            end
         end
      end
    end
    
    
    puts "--------------好评----------------------------"
    puts  dict

    end

    
    
  • 相关阅读:
    查找表类算法//同构字符串
    网页下载器urllib2实例
    网页下载器urllib2实例
    BeautifulSoup实例
    BeautifulSoup实例
    查找表类算法//有效的字母异位词
    查找表类算法//有效的字母异位词
    C++_函数3-引用变量与函数的默认参数
    C++_函数2-内联函数
    C++_函数1-编程的基本模块函数
  • 原文地址:https://www.cnblogs.com/lavin/p/11133120.html
Copyright © 2020-2023  润新知