1. 程式人生 > >大吉大利,今晚吃雞,讓python實現你吃雞的夢想。

大吉大利,今晚吃雞,讓python實現你吃雞的夢想。

視訊獲取: 連結:https://pan.baidu.com/s/1XeCal5szb425eqATcE1F9Q  提取碼:oe1y

原始碼:

import requests
import json
import  jsonpath
import pygal

headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
                      'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36'
}
url = 'http://pg.qq.com/zlkdatasys/data_zlk_zlzx.json'
respose  = requests.get(url,headers = headers)
respose.encoding = 'utf-8'
html = respose.text   #網頁原始碼文字格式
#print(html)

unicodest = json.loads(html)
two = jsonpath.jsonpath(unicodest,'$..yd_c6')#槍的特點
print(two)
three = jsonpath.jsonpath(unicodest,'$..ldtw_f2')#槍的效能
print(three)
four = jsonpath.jsonpath(unicodest,'$..mc_94')  #槍的名字
print(four)
print(four[1:8])
data  = []
num = 0
for a in three:
    if num<7:
        num+=1
        data.append([int(a[0]['wl_45']),int(a[0]['sc_54']),int(a[0]['ss_d0']),int(a[0]['wdx_a7']),int(a[0]['zds_62'])])
        print(data)
radar_chart = pygal.Radar()
radar_chart.title  = '步槍的效能'
radar_chart.x_labels = ['威力','射程','射速','穩定性','子彈數']
for name,property in zip(four[1:8],data):
    radar_chart.add(name,property)
radar_chart.render_to_file('槍支.svg')