How to Scrape QQ Music Song Rankings with Python: A Step‑by‑Step Guide

Learn to retrieve song titles, album names, and playback links from QQ Music’s artist ranking pages using Python’s requests library, parse JSON responses from XHR calls, and store results in Excel, with a complete walkthrough from setup to final summary.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Scrape QQ Music Song Rankings with Python: A Step‑by‑Step Guide

Project Goal

Obtain the song name, album name, and playback link of a specified artist’s songs on QQ Music for a given number of ranking pages.

Required Libraries

requests, json, openpyxl.

Implementation Steps

Understand QQ Music’s robots protocol – only playlists are prohibited.

Open QQ Music homepage https://y.qq.com/ and search for an artist (e.g., G.E.M.).

Open developer tools (Ctrl+Shift+I) and inspect the network panel.

Since the song data is not present in the page source, locate the XHR request that returns JSON data.

In the XHR request, note that the query parameter w represents the artist name and p represents the page number.

Copy the request URL and test it with requests.get to fetch the first page.

Use the params argument of requests.get to specify the artist and page number.

Optionally add headers if needed.

Save the retrieved data to a local file (Excel, CSV, or database).

Sample Code

import requests, json, openpyxl

url = "https://c.y.qq.com/splcloud/fcgi-bin/fcg_music_express_mobile3.fcg"
params = {"w": "邓紫棋", "p": 1, "n": 20, "format": "json"}
response = requests.get(url, params=params)
data = response.json()
# process data and write to Excel

Summary

QQ Music data requires XHR inspection; the information is returned as JSON.

Use requests with appropriate query parameters to fetch song lists.

Store results in Excel for further analysis.

This tutorial is for practice only; avoid excessive crawling that burdens the server.

Future articles will cover lyric and comment scraping with Selenium and word‑cloud generation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonJSONqq music
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.