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