找到七里香這首歌的精彩評論
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='\t') 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 風 於是 開始離開 晴了天\n\n風 於是 開始選擇\n選擇 夏天\n那裡 有下雨 躲雨的屋簷\n\n風 於是 開始選擇 35 307 這首歌,是我愛上的第一首歌。秋刀魚的滋味,是我愛上週董的味道。他唱出了一代人的青春,他是天王,是我 36 308 若天晴少了七里香的芬芳\n那回憶 還算什麼詩一般的盛夏\n於是風鈴 開始搖晃雨季屬於本身的感傷\n但我們 37 '''