Hello everyone, I am Chi Ye!
Not long ago, I found such a short video, “out of the 170 million post-90s generation, only about 10 million couples get married, and the marriage rate is less than 10%.” Of course, we can’t verify the source and authenticity of the data, but I can always hear that my friends complain about the difficulty of getting rid of singles and finding suitable partners.
Today I wrote a simple script in Python to capture the public dating copywriting, to see what kind of people are in the blind date. What are their criteria for choosing a mate? What kind of people are more likely to be single?
The process of writing code
We’ll introduce the libraries we need, using Python’s Requests library to send and receive requests and the regular expression re library to parse the data
import requests
from tenacity import *
import re
import time
Copy the code
Many times a request times out, so when a single error occurs, we try several times, so we use the Retry decorator to make multiple attempts
@retry(stop=stop_after_attempt(5))
def do_requests(url):
response = requests.get(url, headers=headers, proxies=proxies, timeout=10)
return response.text
Copy the code
We capture data including year of birth, height/weight, education, income, occupation, self-introduction, mate criteria, car and garage, all through the regular expression RE library.
Date_of_birth = re.com running (" < br / > 1) birth/constellation < br / > (. *?) ", Re. M | re S) running the sex = re.com (" < br / > (. *?) basic information 】 【 < br / > ") running the height = re.com (" < br / > (2) the height/weight (. *?) < br / > ") education = Running the re.com (" < br / > (5) degree (. *?) < br / > ") jobs_1 = re.com running (" < br / > 6 professional (. *?) < br / > ") income = re.com running (" < br / > 7 monthly income (. *?) < br / > ") I = re.com running (" < br / > pet-name ruby have marriage history (. *?) < br / > ") house_cars = re.com running (" < br / > end garage situation (. *?) < br / > ") self_intro = Re.com running (" < br / > ⑪ self-introduction (. *?) < br / > ") requirements = re.com running (" < br / > [standards] < br / > < / a > (. *?) ") family_member = Re.compile (" compile /> family members (.*?)<br/>")Copy the code
Visual presentation of results
Let’s take a look at the gender ratio first. In terms of the distribution, the proportion of female students coming to blind date is higher, mainly because the data source is blind date from Beijing, Shanghai, Hangzhou and other big cities. In big cities, it seems that it is more difficult for female students to get rid of single.
Let’s take a look at the characteristics of single women. First of all, their ages are mainly around 94, 93 and 95, which are the prime marrying ages
Most of them have a bachelor’s degree, while junior college and master’s degree and doctor’s degree are in the minority
In addition, xiaobian has also done a statistics on the constellations of single women, and found that virgo, Libra, Sagittarius, Aries women have a slightly higher single rate
Finally, let’s take a look at their criteria for choosing a spouse. Xiaobian will separate their criteria for choosing a spouse, and then draw a word cloud
review_list = []
reviews = get_cut_words("".join(df_girls["requirements"].astype(str).tolist()))
reviews_counter = Counter(reviews).most_common(200)
print(reviews_counter)
for review in reviews_counter:
review_list.append((" " + review[0] + " ") * review[1])
stylecloud.gen_stylecloud(text=" ".join(review_list), max_words=500, collocations=False,
font_path="KAITI.ttf", icon_name="fab fa-apple", size=653,
output_name="4.png")
Copy the code
The final appearance is shown below
Visible to the girls on the market, they first is hope that the man is to have a room have a car, before the second if he is married, the girl will be mind, and then if you have a steady job, have the ability to have the sense of responsibility, a good impression on girls, usually as far as the external condition, most of the girl’s answer is height is controlled in 175-180, They are aged between 90 and 97.
Write in the last
In recent years, as people’s ideas have changed, matchmaking has gradually gained acceptance and recognition among young people, especially those with a narrow circle and no access to the opposite sex. I hope everyone can harvest love and have a beautiful life in the end.