Python crawls its own WeChat friend information and makes a friend's signature word cloud

The reference tutorial in this article comes from the WeChat public account [Alfred in New Zealand]. The article is as follows:

" An Interesting Thing: Climbing My Wechat Friends " (click to read the original text to view)


According to the original author's ideas and code, crawl his own WeChat friend information and make a word cloud map of friends' signatures. In this practice, we mainly use itchat, jieba, wordcloud and other packages. The original author uses R for chart visualization, which I will briefly do here. Improved, using the pyecharts package.


About the itchat package, Chinese documentation:

1、https://itchat.readthedocs.io/zh/latest/

2 、 http: //www.cnblogs.com/yanjingnan/p/6831464.html


Github address:

https://github.com/littlecodersh/ItChat/tree/robot


About the pyecharts package:

https://github.com/chenjiandongx/pyecharts


The practice process is as follows:


1. Install the itchat package, log in to WeChat, and crawl information related to WeChat friends.


Install the itchat package: pip install itchat


Crawl WeChat friends related information:

640?wx_fmt=png&wxfrom=5&wx_lazy=1


2. The ratio of men and women who get their WeChat friends

0?wx_fmt=png


3. Install the pyecharts package and draw a gender ratio distribution map

0?wx_fmt=png

0?wx_fmt=png


4. Define a function to climb down friends' nicknames, provinces, cities, genders, signatures and other data and save them to the data frame

0?wx_fmt=png


5. Read the data file and view the distribution of your friend's province


0?wx_fmt=png

(Due to privacy concerns, the read data results are not shown)


0?wx_fmt=png

0?wx_fmt=png


6. Custom word cloud map of WeChat friends' personal signatures

0?wx_fmt=png


0?wx_fmt=png


0?wx_fmt=png

This program is completed through python3, and the encoding problem is not solved in python2. To be continued research.


0?wx_fmt=png

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325484670&siteId=291194637