This is the 17th day of my participation in the August Challenge
Hello, I’m Brother Chen
Today, Brother Chen takes you to analyze a wave of current popular mobile game “King of Glory” hero skin, such as skin online time, skin type (brave; Epic; Legend, etc.), price.
1. Obtain data
The data comes from the official website of King of Glory, and the webpage data is as follows:
Required Contents:
Name of a hero
Hero Skin name
Online time
Skin type (brave; Epic; Legend, etc.)
Price (this is not available officially, but manually calculated by Brother Chen)
First get the data for all skins by looking at network analysis (which is asynchronously loaded)
Viewing response data
url = "https://pvp.qq.com/zlkdatasys/data_zlk_xpflby.json"
response = requests.get(url).json()
for i in response['pcblzlby_c6'] :print(i['pcblzlbybt_d3'],i['lbyrq_e5'],i['pcblzlbyxqydz_c4'])
Copy the code
Here only get the hero skin name, online time and skin details link (including skin type, corresponding hero).
Here we get only 189 skins (9*21=189), and then proceed to the skin details link from the asynchronous request to get specific skin information.
Take one of these skins for example
[Fixed] Get skin type (legend) Skin names (a Midsummer Night’s Dream); Corresponding hero (Diao Chan);
By looking at the source code, you can find the corresponding page tag of the required content, where the skin type is displayed in the form of pictures, but we need the text content, but it is not irregular to find
Skin type rules:
A brave man: 1. The PNG
Limit: 5. PNG
Epic: 12. PNG
Myth: 15. PNG
KPL limited: 19.png
Valentine’s Day limited: 24.png
Glory Collection: 26.png
FMVP: 38. PNG
Order of Battle limited: 40.png
Others: The rest falls into other categories (season limits, etc.)
The pattern above is the text content corresponding to the picture of skin type.
url = "https:"+"//pvp.qq.com/coming/v2/skins/141-5.shtml"
response = requests.get(url)
response.encoding = 'gbk'
text = response.text
selector = etree.HTML(text)
img = selector.xpath('//*[@id="showSkin"]/div/img/@src') [0]
print(frompic_gettext(img))
skin = selector.xpath('//*[@id="showSkin"]/div/div[2]/span[1]/text()') [0]
print(skin)
hero = selector.xpath('//*[@id="showSkin"]/div/div[2]/span[2]/text()') [0]
print(hero)
text = selector.xpath('//*[@id="showSkin"]/div/p/text()') [0]
print(text)
Copy the code
Finally, all (189) skin information was obtained
url = "https://pvp.qq.com/zlkdatasys/data_zlk_xpflby.json"
response = requests.get(url).json()
for i in response['pcblzlby_c6']:
types,skin,hero,text = getdetail(str(i['pcblzlbyxqydz_c4']))
print(hero,skin,i['lbyrq_e5'],types,text)
Copy the code
Output result:
Finally, the data was saved to Excel, and the corresponding price of the skin was calculated manually
In the count column:
1. Direct statistics for those with specific coupon information (excluding first-week discount)
2. Season exclusive 0 (free)
3. Default 388 for order limit (purchase order Advance)
4. Some other lottery, raiders directly with the corresponding text statistics.
Also cleaned up the skin type (e.g. 50/50 black festival, ox year limit, etc.)
2. The visualization
Let’s start with a word cloud for the number field
The visual platform of Chen Ge is used directly here
(show.chenlove.cn)
The following visualizations are generated directly from the platform above with one click
Upload the previous Excel file,
Select the number field and word cloud background;
Click to generate word cloud
Click Export to download it locally
Also make word cloud for skin field with one click
On-line time analysis
Count the number of skins released each year
df = pd.read_excel("King of Glory Hero Skin.xlsx")
time = df["Launch time"].tolist()
clear_time = [str(i)[0:4] for i in time]
result = Counter(clear_time)
# sort
d = sorted(result.items(), key=lambda x: x[1], reverse=True)
t = [i[0] for i in d]
v = [i[1] for i in d]
"" "' 2020 ', '2019', '2021', '2018', '2017'] [14] 43, 44, 47, 42, "" "
Copy the code
Again, use chenge’s visualization platform (select pie chart)
Visualize the results
It can be seen that the number of online skin increased year by year from 2017 to 2021. Since 2021 is just over half, the number of online skin has not exceeded 2020.
Analysis of the month of the year when the number of skin
The month with the largest number of skin from 2017 to 2021 was counted
for j in [str(i)[0:6] for i in time]:
if "2017" in str(j):
t_2017.append(j[4:6])
if "2018" in str(j):
t_2018.append(j[4:6])
if "2019" in str(j):
t_2019.append(j[4:6])
if "2020" in str(j):
t_2020.append(j[4:6])
if "2021" in str(j):
t_2021.append(j[4:6])
# sort
d_2017 = sorted(Counter(t_2017).items(), key=lambda x: x[1], reverse=True)
d_2018 = sorted(Counter(t_2018).items(), key=lambda x: x[1], reverse=True)
d_2019 = sorted(Counter(t_2019).items(), key=lambda x: x[1], reverse=True)
d_2020 = sorted(Counter(t_2020).items(), key=lambda x: x[1], reverse=True)
d_2021 = sorted(Counter(t_2021).items(), key=lambda x: x[1], reverse=True)
print("2017",d_2017[0])
print("2018",d_2018[0])
print("2019",d_2019[0])
print("2020",d_2020[0])
print("2021",d_2021[0])
"" 2017" (10, 3), 2018 (' 10 ', 6), 2019 (' 02 ', 10) 2020 (' 01 ', 14) 2021 (' 02 ', 10) "" "
Copy the code
It can be seen that there are more skin online in October 2017 and 2018. Since the beginning of 19th year, the number of skin online in that month is more than that in other months of the same year.
Different ticket prices
In excel, a column of counting coupons contains several prices, and sort them
price = df["Point"].tolist()
clear_price = [str(i) for i in price]
result = Counter(clear_price)
# sort
d = sorted(result.items(), key=lambda x: x[1], reverse=True)
t = [i[0] for i in d]
v = [i[1] for i in d]
"" "' 888 ', '1788', '0', '388', '1688', '60', 'thing', '488', 'draw', 'noble limit', '660'] [52, 30, 28, 21, 19, 17, 13, 6, 2, 1, 1) "" "
Copy the code
Import the results into the visualization platform to generate the visualization map
The third one is 0, because the season skin can be obtained for free (the required point coupon is 0), the above is the price of king of Glory skin, like raiders of the Treasure lottery, it is not possible to measure the point coupon, so it directly shows the Chinese meaning.
Several different skin types
Statistics excel type fields, and sort
"" "[' epic ', 'brave', 'limited', 'war to limit', 'other', 'season limit', 'KPL limit', 'FMVP', 'glory collection', 'qualified valentine's day', 'year of the rat is limited,' pig year limit ', 'the year of the ox is limited,' 50-50 black day ', 'legends', To mark the fifth anniversary of 'dog limit', 'limited', 'the fourth anniversary of the limit,' third anniversary limited ', 'team and the exclusive', '2-year limit] [27, 27, 26, 21, 20, 18, 9, 6, 6, 5, 5, 5, 4, 2, 2, 2, 1, 1, 1, 1, 1) "" "0
Copy the code
The current count is 20 types, but far more than 20, because the “other” label also includes many, so skin type at least 20+, estimated more than 20. It can also be seen that the two types of epic and brave have more skins.
The same kind of dots corresponds to different skin types
The same coupon price corresponds to multiple skin types
For example 888 points for ‘limited ‘,’ epic ‘, ‘KPL Limited ‘, ‘Fifty-five Black Day ‘,’ Valentine’s Day Limited ‘, etc.
The statistical points were 888; 1788; 1688; 0 (free) which skin types to map (again using visualization platform)
for i in range(0.len(price)):
if str(price[i])=="888":
if tp[i] not in c_888:
c_888.append(tp[i])
if str(price[i])=="1788":
if tp[i] not in c_1788:
c_1788.append(tp[i])
if str(price[i])=="0":
if tp[i] not in c_0:
c_0.append(tp[i])
if str(price[i])=="1688":
if tp[i] not in c_1688:
c_1688.append(tp[i])
"" "888 [' limited ', 'epic', 'KPL limit', '50-50 black day', 'qualified valentine's day', 'brave' and 'pig year limit', 'other', '2-year limit] 1788 [' limited' and 'qualified valentine's day', 'the year of the ox limit', 'KPL is limited, 'year of the rat limit, limit' pig ', 'limited' in the year of dog] 0 [' other ', 'season limit', 'the fifth anniversary of limited,' the fourth anniversary of the limited ', 'brave', 'third anniversary limited', 'team and the exclusive] 1688 [' limited' and 'FMVP', 'legends',' other '] "" "
Copy the code
888 coupons correspond to skin type
1788 coupons correspond to skin type
Zero coupons correspond to skin type
1688 coupons correspond to skin type
That’s all for today’s article
All the visualizations mentioned above are made through the visual platform of Brother Chen. (show.chenlove.cn)
The last
1. This article details how python crawlers capture and visualize the hero skin information in Honor of Kings
2. This article is only for readers to learn to use, not for other purposes!