How to Scrape NetEase Cloud Music Hot Comments with Python
This tutorial walks through using Python and browser developer tools to locate, decode, and retrieve the hot comments from NetEase Cloud Music's hot song chart, including extracting song IDs, handling encrypted request parameters, and applying regex to gather song metadata.
The author, a beginner in Python web scraping, aims to collect the hot comments from the NetEase Cloud Music hot song chart to practice crawling techniques.
First, open the NetEase Cloud Music website and navigate to the "Hot Songs" chart. Using the browser's developer tools (F12), switch to the Network tab and refresh the page to capture all requests.
Among the many requests, filter by status code 200 and preview the response to locate the request that contains the comments. The relevant request URL follows the pattern:
http://music.163.com/weapi/v1/resource/comments/R_SO_4_489998494?csrf_token=Here R_SO_4_ is a fixed prefix and the trailing numbers represent the song's unique ID.
The POST request also includes two encrypted parameters, params and encSecKey. These values differ per song and page but can be reused across songs for the same page number. By copying the params and encSecKey from any song’s first page request, you can retrieve the first 15 hot comments (the hotComments field in the JSON response).
To obtain the list of all songs in the hot chart, repeat the process: open the chart page, inspect network traffic, and find a GET request like toplist?id=3778678 that returns the full song list.
Using regular expressions on the returned HTML, extract each song’s name and ID. The two regex patterns used are:
<ul class="f-hide"><li><a href="/song?id=d*?">.*</a></li></ul> <li><a href="/song?id=d*?">(.*?)</a></li> <li><a href="/song?id=(d*?)">.*?</a></li>After extracting the song names and IDs, you can construct the comment‑fetching URLs for each song as described above.
Below are the key screenshots illustrating each step:
By following these steps, you can programmatically collect high‑quality hot comments and song metadata from NetEase Cloud Music.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
