Fundamentals 6 min read

Create Stunning Word Clouds from WeChat Moments Using Python and Jieba

This tutorial walks you through extracting WeChat Moments with a Python web scraper, processing the Chinese text using jieba, and visualizing the most frequent words as beautiful word clouds with customizable shapes and fonts.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Create Stunning Word Clouds from WeChat Moments Using Python and Jieba

We previously scraped WeChat Moments data using a Python web crawler; now we will visualize the text with a word cloud.

Step 1: Install the wordcloud and jieba libraries via pip install wordcloud jieba.

Step 2: Download a Chinese font such as simhei.ttf for rendering Chinese characters in the cloud.

Step 3: Create analyse.py alongside items.py and define analyse_words. Load the scraped moment.json file (ensure encoding='utf-8' to avoid GBK errors) and use jieba.cut to obtain word segmentation.

Step 4: Run the program; it generates keys.png in the items.py directory.

Step 5: Open keys.png to view the initial word‑cloud result.

Step 6: The default cloud looks cluttered; improve its appearance using the online tool WordArt.

Step 7: Try different shapes, such as an animal silhouette, for a more attractive visual.

Step 8: To avoid overly dense text, preprocess the JSON data: extract all text into moment.txt.

Step 9: Perform word segmentation on the extracted text.

Step 10: The segmentation output is saved to moment_outputs.txt, showing the token list.

Step 11: Count word frequencies and write the results to a text and Excel file.

Step 12: The frequency table is displayed without errors.

Step 13: Import the keyword‑frequency list into WordArt for final visualization.

Step 14: Adjust shape, font, layout, and colors to produce a colorful cloud, e.g., a dog‑shaped word cloud.

Step 15: Create additional designs such as a cloud‑shaped word cloud for a visual feast.

Feel free to bookmark, share, or repost this guide if you find it useful.

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.

PythonData visualizationtext miningWeb Scrapingjiebaword cloud
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.