09、 在QQ音乐中查找七里香这首歌的精彩评论

   找到七里香这首歌的精彩评论
 
   URL https://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg?g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=GB2312¬ice=0&platform=yqq.json&needNewCode=0&cid=205360772&reqtype=2&biztype=1&topid=102065756&cmd=8&needmusiccrit=0&pagenum=0&pagesize=25&lasthotcommentid=&domain=qq.com&ct=24&cv=10101010
 
 1 #9 在QQ音乐中查找七里香这首歌的精彩评论
 2 #   找到七里香这首歌的精彩评论
 3 #   URL https://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg?g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=GB2312¬ice=0&platform=yqq.json&needNewCode=0&cid=205360772&reqtype=2&biztype=1&topid=102065756&cmd=8&needmusiccrit=0&pagenum=0&pagesize=25&lasthotcommentid=&domain=qq.com&ct=24&cv=10101010
 4 
 5 import requests
 6 
 7 res = requests.get('https://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg?g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=GB2312¬ice=0&platform=yqq.json&needNewCode=0&cid=205360772&reqtype=2&biztype=1&topid=102065756&cmd=6&needmusiccrit=0&pagenum=0&pagesize=15&domain=qq.com&ct=24&cv=10101010')
 8 
 9 html = res.json()
10 pages = int(html['comment']['commenttotal'] / 15 + 1)
11 
12 item_num = 0
13 
14 for i in range(0,pages):
15     res = requests.get('https://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg?g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=GB2312¬ice=0&platform=yqq.json&needNewCode=0&cid=205360772&reqtype=2&biztype=1&topid=102065756&cmd=6&needmusiccrit=0&pagenum={}&pagesize=15&domain=qq.com&ct=24&cv=10101010'.format(i))
16     html = res.json()
17     items = html['comment']['commentlist']
18 
19     for item in items:
20         item_num = item_num + 1
21         print(item_num,end='	')
22         try:
23             print(item['rootcommentcontent'])
24         except KeyError:
25             print(item['middlecommentcontent'][0]['subcommentcontent'])
26 
27 '''
28 执行结果如下:
29 1       这首歌唤醒了所有关于你的记忆,我又看见了你帮我画手抄报的侧颜,听见了我们九月里散步踩碎落叶的响声,
30 2       那年夏天的黄昏将泥砌的墙涂成炽热颜色,窗外麻雀窃窃私语着什么,院内梧桐叶层层叠叠,我忧心着麻雀忘记
31 3       七月的知了将夏天唤醒,手中的铅笔在稿纸上肆意的涂鸦。房间里散发着栀子花香,淡风轻轻拂动淡色的窗帘。
32 
33 
34 305     风 于是 开始离开 晴了天

风 于是 开始选择
选择 夏天
那里 有下雨 躲雨的屋檐

风 于是 开始选择
35 307     这首歌,是我爱上的第一首歌。秋刀鱼的滋味,是我爱上周董的味道。他唱出了一代人的青春,他是天王,是我
36 308     若天晴少了七里香的芬芳
那回忆 还算什么诗一般的盛夏
于是风铃 开始摇晃雨季属于本身的感伤
但我们
37 '''
 
 
 
原文地址:https://www.cnblogs.com/www1707/p/10692380.html