Scrape WeChat Group Avatars and Rank Them with Python & Baidu AI
This article walks through using Python to download all WeChat group member avatars, save them locally, and then apply Baidu's face‑recognition API to evaluate age, gender and beauty scores, finally filtering and ranking the images based on the results.
Inspired by a class group chat, the author decided to rank classmates' profile pictures by perceived attractiveness using Python.
1. Download group avatars
The author chose to avoid WeChat SDKs like itchat or wxpy and instead accessed the web version of WeChat. After scanning the QR code and logging in, the server returns user information in three POST requests, each delivering up to 50 user records (nickname, group nickname, avatar URL, gender, region, etc.).
By reproducing the request payload found in the web traffic, the script can fetch the complete list of members and extract each avatar URL.
2. Save avatars locally
Using the same session, the script iterates over the avatar URLs and downloads each image, naming the files with the corresponding group nickname. The downloaded images are stored in a local img folder.
3. Register Baidu AI and obtain credentials
Sign up for a Baidu Cloud account, create a Face Recognition application, and note the API Key and Secret Key , which are required to request an access_token.
4. Build the token request function
The script defines a get_access_token function that sends a request with the API Key and Secret Key and receives the access_token needed for subsequent face‑analysis calls.
5. Analyze each avatar
For every saved image, the script calls Baidu's face detection endpoint, receiving attributes such as age, gender, facial shape, smile intensity, and a beauty score. The author keeps only gender, age, and beauty for ranking.
6. Filter and rank results
After obtaining the analysis, the script discards non‑female faces, saves the remaining data (including beauty scores) into a spreadsheet, and produces a ranking of the female avatars based on the AI‑generated scores.
The final ranking was shared back to the WeChat group, illustrating a playful yet technically detailed use of web scraping and AI face analysis.
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.
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!
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.
