Ruby初学练习->利用QQ接口查询QQ号信息文章

2016-06-20  本文已影响388人  D0be

QQ信息查询

利用QQ接口查询QQ号信息

ruby练习

require 'net/http'
    require 'json'
    
    uri = URI.parse("http://ti.qq.com/cgi-bin/more_profile_card/more_profile_card")
    http = Net::HTTP.start(uri.host,uri.port)
    req = http.post(uri,"_q=#{$*[0]}&bkn=1018562703&src=mobile",header = {'cookie'=>"Your Cookie"})
    content = req.body
    obj = JSON.parse(content)
    profile = obj['profile'][0]
    birthday = profile['birthday']
    home = profile['hometown_country']+profile['hometown_state']+profile['hometown_city']+profile['hometown_area']
    location = profile['location_country']+profile['location_state']+profile['location_city']+profile['location_area']
    puts "年龄:#{profile['age']}"
    puts "生日:#{birthday['year']}-#{birthday['month']}-#{birthday['day']}"
    puts "性别:#{profile['gender']}"
    puts "昵称:#{profile['nick']}"
    puts "故乡:#{home}"
    puts "所在地:#{location}"
    puts "大学:#{profile['college']}"
    puts "公司:#{profile['company']}"
    puts "邮箱:#{profile['email']}"
    puts "个人简介:#{profile['personal']}"
6631727472675249426.jpg
上一篇下一篇

猜你喜欢

热点阅读