I Scraped Bilibili Game Data and Found Some Interesting Things
Background
It went like this.
One night I was browsing the Bilibili Game Center and noticed that some games had high ratings but low download counts. Others had average ratings but high download counts.
I wondered whether there were any patterns among these data points.
So I wrote this scraper.
Project Overview
This project does something simple: it scrapes data from the Bilibili Game Center, then performs analysis and visualization.
The scraped data includes game names, genres, platforms, ratings, follower counts, download counts, ranking data, and more.
The analysis covers genre distribution, platform distribution, rating distribution, the relationship between follower counts and downloads, revenue estimation, and more.
Data Acquisition Modes
The project supports three data acquisition modes:
| Mode | Description | Use Case |
|---|---|---|
demo |
Built-in simulated data for 88 real domestic games | Development and debugging, offline demos |
web |
Parse from Bilibili Game Center HTML pages | Actual data collection |
api |
Call Bilibili API endpoints | Actual data collection |
demo mode is for people who don’t want to scrape data and just want to see what the analysis looks like. It includes data for 88 real domestic games. Although it isn’t the latest, it’s enough for a demo.
web mode gets data by parsing HTML pages. It doesn’t require an API key, but it’s a bit slower.
api mode calls Bilibili’s API directly. It’s fast, but you may need to deal with anti-scraping measures.
Revenue Estimation
The most interesting part of this project is revenue estimation.
The Bilibili Game Center does not publish game revenue data, so I can only estimate it through other metrics. The metrics I used are follower counts and ratings.
Follower counts represent a game’s popularity, and ratings represent its quality. A game with high popularity and high quality is very likely to have decent revenue.
The estimation formula is simple: revenue = follower count * rating coefficient * platform coefficient. This formula is not precise, but it can show the general trend.
Visualization
The project generates 7 types of charts:
- Game genre distribution pie chart
- Platform distribution bar chart
- Rating distribution histogram
- Follower count vs. download count scatter plot
- Estimated revenue ranking chart
- Popularity ranking TOP10
- Top-grossing ranking TOP10
These charts are generated with Matplotlib. The styling is average, but the data is accurate. If you want better-looking charts, you can switch to ECharts or Plotly yourself.
Some Findings
After scraping the data, I found some interesting things:
Anime-style games generally have higher ratings. This may be because anime-style game players are more willing to give high scores.
For indie games, follower counts and download counts are not proportional. Some indie games have high follower counts but low download counts. This may be because players only bookmark them and don’t actually play them.
Popular games in the Bilibili Game Center are not quite the same as popular games on the App Store. Bilibili users prefer anime-style, indie, and niche games.
Games on the pre-registration chart perform unevenly after launch. A high pre-registration count doesn’t mean the game is good; it may just mean the marketing was good.
These findings aren’t particularly deep insights, but I find them quite interesting.
Project Structure
1 | bgame/ |
Quick Start
1 | # 安装依赖 |
Pitfalls I Encountered
Pitfall 1: Anti-Scraping
Bilibili has anti-scraping mechanisms, and making requests too frequently can get your IP blocked. I added random delays and User-Agent rotation, but sometimes I still got blocked.
Pitfall 2: Data Format
The data format in the Bilibili Game Center is not very consistent. Some games have empty fields, and some games have fields in different formats. I wrote several parsers to handle these special cases.
Pitfall 3: Pagination
The pagination logic in the Bilibili Game Center is a bit strange. Sometimes requesting the first page returns duplicate data. I only solved this problem by adding deduplication logic.
Open Source
Project address: yfgug/bgame
If you’re interested in Bilibili game data, you can check it out. The code is average, but the functionality is complete.
Final Thoughts
I used this project to practice Python scraping. After finishing it, I realized that scraping isn’t technically difficult; the hard part is handling all kinds of edge cases.
Anti-scraping, data formats, pagination, encoding… every step can go wrong. Writing a scraper is like a battle of wits with the website’s developers. Sometimes you win, sometimes you lose.
But the data you finally scrape can indeed reveal some interesting things.
That’s probably the charm of data.
“Data is the oil of the new era, and analysis is the refinery.”