current position:Home>Using Python to analyze 2,000 thousand confession walls of a university, I saw the secret of their divorce

Using Python to analyze 2,000 thousand confession walls of a university, I saw the secret of their divorce

2022-09-09 06:38:31happy planet no joy

good college days,It is a paradise for youth,From the heavy high school life to the colorful college life,Freed from a lot of shackles.Think back to college life,Everyone has some ignorant youth memories,Many friends must also know the confession wall of the university,Maybe you are still leaving a message on the confession wall or being confessed by others.

Now that I think about it, it's still very sweet?今天,I will lead you to use itPythonGrab a college confession wall,Relive fond memories of your college days.


There are thousands of college confessions on the college confession wall page,You can choose any school to grab,Each school has its own confession wall homepage,Homepages belong to the category of static web pages,如下图所示:

In the picture above, we want to express the content of each page,We want to capture the names of the confessed and the confessor and the contents of the confession,核心代码如下:

由于网页属于静态网页,And there is no complicated anti-reptile means,Therefore, there is no particularly complicated content in the writing of the program,Programs use loops,Construct web links for each page,Then extract the information we want to get,Finally, the extracted information can be saved to a local file.


这里,The editor grabbed the total of a certain college2512条confession information.Next, let's analyze the information obtained by grabbing it.

1).Who is the king of confession

Positive confessor,It represents a person's liking for a person,yearning for love,But in terms of expression,Often more shy,He did not want to reveal his real name.through the following procedure,Let's count the number of confessors,Take a look at everyone's signature information on the confession wall.

its visualization results,让人大跌眼镜,Everyone is so shy!

可以看到,超过93%The professors are treated anonymously,And among those with higher confession signatures,He didn't leave his real name.It can be seen that everyone is still very shy,I don't want to reveal my name.

2).Who is the star who has been confessed

A person can be confessed,It shows the excellence of a person,It's something to be proud of.We utilize histogram visualization,Let's see who is the star who is being confessed.The program and visualization results are shown in the figure below:

可以看到,Unlike the confessor,The names of those who were confessed were very diverse,And there are real personal names.

There are also people“经管”、“教育学院”Confession occurs.This situation may be the college of the person being confessed to or the confessor's confession to his own college.

3).Which college has been confessed the most

The more times you are confessed,To a certain extent, it shows that there are more beautiful and handsome men in the academy,This also points us in the direction of finding the object of confession,The editor remembers that when I was in college, the most beautiful women should be新闻系,Department of Media,反而电子,自动化,There are not many beauties in computer school.

上图程序中,First, use keyword matching to match different colleges,然后利用pyecharts下的LineClasses are displayed visually.

from the visualized results,可以看到,教育学院、School of Psychology and School of Economics and ManagementRanked in the top three in the number of confessed colleges,Students of this college can pay more attention to these colleges,You might find someone you like. keywords

最后,我们来看一下,Confession word cloud,Take a look at what keywords are in your statement.

可以看到,Everyone's confession word cloud,包含了“喜欢”、“我爱你”、“我们”等关键词.最后,Let's look at a few statements of confession.

  • But I saw your first glance,I felt familiar,直到后来我才明白,This is Yue Lao who brought the two of us together with a red thread,May you be well every day,It's sunny here for me.

  • 初次遇见,Silly and sweet you,Like a princess in a fairy tale.Every boy has a princess who longs to protect,And you are my princess.爱你!

  • Actually, I want to tell you a lot,We still need time to grow and settle,愿你天天开心!Love you, love you, love you for ten thousand years!

The above is the analysis and sharing of the confession wall brought to you by Xiaobian,In fact, if you like someone, you have to be brave and say it,Maybe the other party is waiting for a brave confession from you.


学好 Python 不论是就业还是做副业赚钱都不错,但要学会 Python 还是要有一个学习规划.最后大家分享一份全套的 Python 学习资料,给那些想学习 Python 的小伙伴们一点帮助!




















copyright notice
author[happy planet no joy],Please bring the original link to reprint, thank you.

Random recommended