查询车系特定口碑信息
特定车系口碑信息(智能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
浙公网安备 33010602011771号