Create Stunning Word Cloud Visualizations from WeChat Moments with Python

This tutorial walks you through using Python's wordcloud and jieba libraries to process WeChat Moments data, generate frequency statistics, and produce attractive, shape‑based word cloud images, complete with code snippets and visual examples.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Create Stunning Word Cloud Visualizations from WeChat Moments with Python

Previously we used a Python web crawler to collect data from WeChat Moments; now we visualize that data with a word cloud.

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

2. Download a Chinese font such as simhei.ttf for rendering the cloud.

3. In the same directory as items.py, create analyse.py and define an analyse_words function that uses jieba.cut to segment the JSON data from moment.json. Remember to open the file with encoding='utf-8' to avoid GBK encoding errors.

4. Run the program to generate keys.png in the items.py folder.

5. Open keys.png to view the initial word cloud.

6. The default cloud may look plain, so we use the online tool WordArt to beautify it.

7. Choose an animal shape (e.g., a dog) for a more appealing visual.

8. To avoid clutter in WordArt, first extract all text from the JSON into a moment.txt file.

9. Write code to segment the text; the implementation is shown in the tutorial images.

10. After running, moment_outputs.txt displays the segmentation results.

11. Write additional code to count word frequencies; the implementation is illustrated.

12. Running this code produces a text file and an Excel sheet containing the frequency statistics.

13. Import the keywords into WordArt for visualization.

14. Adjust shape, font, layout, and colors to generate a vibrant dog‑shaped word cloud.

15. Another example creates a fluffy cloud‑shaped word cloud for a visual feast.

Feel free to bookmark, share, and explore the full source code on GitHub: https://github.com/cassieeric/wechat-circle-of-friends

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.

Pythontext miningjiebawordcloud
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.