Home Backend Development Python Tutorial Python crawls Leslie Cheung's 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

Python crawls Leslie Cheung's 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

Apr 02, 2019 pm 02:19 PM
python



Yesterday was April 1st.

On this day every year,

some people search hard and think of ways to play tricks,

some people feel that April would be great, if you are still here.

There are even people who use AI to restore you.

But it’s not you after all.

Python crawls Leslie Cheungs 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

See watermark for picture source

It’s been 16 years since you left. Those teenagers who secretly listened to your songs at the desk when the teacher wasn’t paying attention, Perhaps she has been a husband and a wife for a long time.

Even so, every year, many people miss you and leave you messages through the endless echoes you leave to the world in April. Even if they know it clearly, they will never A reply will be received.

640 (1).gif

Now, we choose to use technology to commemorate our brother.

We crawled your eight songs with the most comments on NetEase Cloud Music.

They are: "Silence is Golden", "Spring, Summer, Autumn and Winter", "A Chinese Ghost Story", "When Love Is a Past", "Me", "The Wind Keeps Blowing", "The Love of Glass" and "When the Wind Rises Again".

Among the 64,540 comments in total, the most common ones were "Happy birthday," "Brother," "Come on," "If you are still here," "Happy New Year," and "Happy birthday, brother."

Python crawls Leslie Cheungs 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

There are very few words like "April 1st" and "April Fool's Day" in the word cloud chart. This is not because there are few people commenting on this day, but because On this day, it is really not the right time to say "Happy" to you.

Come on, let me show you the code of the comment first.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

# coding:utf-8

import json

import time

import requests

from fake_useragent import UserAgent

import random

import multiprocessing

import sys

#reload(sys)

#sys.setdefaultencoding('utf-8')

 

ua = UserAgent(verify_ssl=False)

 

song_list = [{'186453':'春夏秋冬'},{'188204':'沉默是金'},{'188175':'倩女幽魂'},{'188489':'风继续吹'},{'187374':'我'},{'186760':'风雨起时'}]

headers = {

    'Origin':'https://music.163.com',

    'Referer': 'https://music.163.com/song?id=26620756',

    'Host': 'music.163.com',

    'User-Agent': ua.random

}

 

def get_comments(page,ite):

    # 获取评论信息

    # """

    for key, values in ite.items():

        song_id = key

        song_name = values

    ip_list = [IP列表]

    url = 'http://music.163.com/api/v1/resource/comments/R_SO_4_'+ song_id +'?limit=20&offset=' + str(page)

    proxies = get_random_ip(ip_list)

    try:

        response = requests.get(url=url, headers=headers,proxies=proxies)

    except Exception as e:

        print (page)

        print (ite)

        return 0

    result = json.loads(response.text)

    items = result['comments']

    for item in items:

        # 用户名

        user_name = item['user']['nickname'].replace(',', ',')

        # 用户ID

        user_id = str(item['user']['userId'])

        print(user_id)

        # 评论内容

        comment = item['content'].strip().replace('\n', '').replace(',', ',')

        # 评论ID

        comment_id = str(item['commentId'])

        # 评论点赞数

        praise = str(item['likedCount'])

        # 评论时间

        date = time.localtime(int(str(item['time'])[:10]))

        date = time.strftime("%Y-%m-%d %H:%M:%S", date)

Copy after login

Lyric codes for eight songs:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

import requests

from bs4 import BeautifulSoup

import re

import json

import time

import random

import os

 

headers = {

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3355.4 Safari/537.36',

    'Referer': 'http://music.163.com',

    'Host': 'music.163.com'

}

 

 

# 获取页面源码

def GetHtml(url):

    try:

        res = requests.get(url=url, headers=headers)

    except:

        return None

    return res.text

 

 

# 提取歌手歌词信息

def GetSongsInfo(url):

    print('[INFO]:Getting Songs Info...')

    html = GetHtml(url)

    soup = BeautifulSoup(html, 'lxml')

    links = soup.find('ul', class_='f-hide').find_all('a')

    if len(links) < 1:

        print(&#39;[Warning]:_GetSongsInfo <links> not find...&#39;)

    Info = {&#39;ID&#39;: [], &#39;NAME&#39;: []}

    for link in links:

        SongID = link.get(&#39;href&#39;).split(&#39;=&#39;)[-1]

        SongName = link.get_text()

        Info[&#39;ID&#39;].append(SongID)

        Info[&#39;NAME&#39;].append(SongName)

    # print(Info)

    return Info

 

 

def GetLyrics(SongID):

    print(&#39;[INFO]:Getting %s lyric...&#39; % SongID)

    ApiUrl = &#39;http://music.163.com/api/song/lyric?id={}&lv=1&kv=1&tv=-1&#39;.format(SongID)

    html = GetHtml(ApiUrl)

    html_json = json.loads(html)

    temp = html_json[&#39;lrc&#39;][&#39;lyric&#39;]

    rule = re.compile(r&#39;\[.*\]&#39;)

    lyric = re.sub(rule, &#39;&#39;, temp).strip()

    print(lyric)

    return lyric

 

 

def main():

    SingerId = input(&#39;Enter the Singer ID:&#39;)

    url = &#39;http://music.163.com/artist?id={}&#39;.format(SingerId)

    # url = "http://music.163.com/artist?id=6457"

    Info = GetSongsInfo(url)

    IDs = Info[&#39;ID&#39;]

    i = 0

    for ID in IDs:

        lyric = GetLyrics(ID)

        SaveLyrics(Info[&#39;NAME&#39;][i], lyric)

        i += 1

        time.sleep(random.random() * 3)

        # print(&#39;[INFO]:All Done...&#39;)

 

 

def SaveLyrics(SongName, lyric):

    print(&#39;[INFO]: Start to Save {}...&#39;.format(SongName))

    if not os.path.isdir(&#39;./results&#39;):

        os.makedirs(&#39;./results&#39;)

    with open(&#39;./results/{}.txt&#39;.format(SongName), &#39;w&#39;, encoding=&#39;utf-8&#39;) as f:

        f.write(lyric)

Copy after login

01

"Silence is Golden"

It’s wrong, it’s never right, it’s always true

No matter what you say, I’ll stick to my duty

Always believe silence is golden


This song was composed by you yourself.

At that time, the "Tan-Chang Hegemony" (from 1986 to 1989, Alan Tam and Leslie Cheung launched a comprehensive competition in music to compete for status in the music industry) had entered a fever pitch.

You hate fighting, so you borrowed a song to express your ambition and released "Silence is Golden".

You said, "No matter what you say, I will stick to my duty and always believe that silence is golden."

The pure will purify themselves, and your silence will further demonstrate your innocence.

02

《Spring, Summer, Autumn and Winter》

Autumn should be great if you are still here

Even if the autumn wind is cool, it is still beautiful

You in the late autumn fill my dreams

Like fallen leaves flying and tapping on my window


Every time it’s your birthday, every New Year, or every day you leave this world, there will be a lot of comments under your songs.

You left on April 1st, but people who like you always come to comment on your music on March 30th, 31st or even earlier.

So many people hope that you will be resurrected. Some people even saw a taxi driver in Chongqing who looked very similar to you and couldn't help but take a picture.

The clarity and hesitation in your eyes are still so unforgettable after all these years.

Python crawls Leslie Cheungs 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

03

##《A Chinese Ghost Story》

Beautiful Dreams in the Red Dust How many directions are there

Looking for the love of the crazy dream

The road is endless with people

640 (2).gif

In "A Chinese Ghost Story", you are shy The timid scholar would light three lanterns when walking at night, but for fear that the sunlight would scatter Xiaoqian's soul, he would hold the door panel firmly on his shoulders.

Xiaoqian left, and Ning Caichen's heart died.

My brother is gone, and if someone else plays Ning Caichen, I always feel that Wushan is not Yun.

04


##"When Love Is a Past"

Why don’t you understand

As long as there is love, there will be pain

One day you will know

Life will not be different without me


In "Farewell My Concubine", you played Cheng Dieyi.

You acted so charmingly that some people asserted that you were born in Tongzi Gong.

Actually, you are just continuing to train despite being seriously ill.

You said "If you don't go crazy, you won't survive", so you know that after Duan Xiaolou marries a wife, he will be jealous, sad and crazy.

You have loved both on and off the screen. You said, "As long as there is love, there will be pain", but it is more like singing it to yourself.

Python crawls Leslie Cheungs 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

You are so pure and "accepting death" that your fans always feel sorry for you...

05


《我》

The same nakedness that blooms in the lonely desert

How happy Live happily in the glass house

What is light and aboveboard to the world

I am I am fireworks with different colors


How many people use the phrase you sang, "I am who I am, just like fireworks of different colors" to encourage themselves to live out their lives.

But in the end you left this world like fireworks.

A few years ago, Tony Leung dialed your phone number at a concert to commemorate you.

On the phone, the message was still there, "Hello, I'm Leslie, please leave a message if you need anything."

Python crawls Leslie Cheungs 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

Liang Chaowei was silent, and after a long time, he said calmly Sentence: "Baorong, why don't we start from scratch."

06


《风continues to blow》

The wind continues to blow and I can’t bear to stay away

There are tears in my heart and I don’t want to shed tears as I look at you

So many happy memories in the past

Why not chase it with you


This is your famous song, so you seem to like it very much.

Every time I attend a concert, I have to sing.

When you sang for the last time, you cried for some reason, and the audience also cried with you.

Python crawls Leslie Cheungs 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

Python crawls Leslie Cheungs 8 most popular songs, with 60,000 comments and I burst into tears after reading them!

Because this song is a testimony of your turnaround.

You have been in the music industry for so many years, but you have always been silent. This song has prevented you from being buried.

07


##"Glass Love"

Don’t believe in tears It can make you fall in love again when you are disappointed.

The hard-to-recover water will spread the feelings away

There is no crime in saying goodbye in time if you are too tired


You once said that every time you sing, you have to make up a story for the song. When you sing, the picture of the story comes to your mind, and this sense of picture makes you very immersed in singing.


Why your songs last forever is because you not only attach great importance to people, but also to songs.

08

《When the Wind Rises Again》


I look back to a certain year

Like a faded photo appearing before my eyes

This confused boy

May I devote my life to singing every day and never change


In 1989, having seen too many ups and downs in the entertainment industry, you suddenly announced your farewell to the music industry.


You have seen the hustle and bustle, but you are not part of the hustle and bustle.


Before planning the farewell concert, you discussed it with musicians Chen Shaoqi and Li Xiaotian.

Chen Shaoqi said, "Don't you have a famous song called "The Wind Continues to Blow"? Why don't you just call it "When the Wind Rises Again"? I just hope that when the wind blows again, fans will think of you." Song."

Li Xiaotian next to him spent fifteen minutes composing the song on a random piece of paper.

Soon, Chen Shaoqi also filled in the words.

Some people say that the lyrics in this song are tailor-made for you: "I look back to a certain year, and like a faded photo suddenly appears in front of my eyes, this confused young man is willing to sing and devote himself to it all his life. It never changes every day.”


May I spend my whole life singing and devoting myself to every day forever...

640 (3).gif


I wonder if you are still singing now? Are you still acting?

Do you know that many people are thinking of you.

Thank you for leaving us so many songs and movies.

May you never be depressed or sad in another world.

above.

This article has ended here. For more exciting content, you can pay attention to the Python Video Tutorial column on the PHP Chinese website! ! !

The above is the detailed content of Python crawls Leslie Cheung's 8 most popular songs, with 60,000 comments and I burst into tears after reading them!. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Do mysql need to pay Do mysql need to pay Apr 08, 2025 pm 05:36 PM

MySQL has a free community version and a paid enterprise version. The community version can be used and modified for free, but the support is limited and is suitable for applications with low stability requirements and strong technical capabilities. The Enterprise Edition provides comprehensive commercial support for applications that require a stable, reliable, high-performance database and willing to pay for support. Factors considered when choosing a version include application criticality, budgeting, and technical skills. There is no perfect option, only the most suitable option, and you need to choose carefully according to the specific situation.

How to use mysql after installation How to use mysql after installation Apr 08, 2025 am 11:48 AM

The article introduces the operation of MySQL database. First, you need to install a MySQL client, such as MySQLWorkbench or command line client. 1. Use the mysql-uroot-p command to connect to the server and log in with the root account password; 2. Use CREATEDATABASE to create a database, and USE select a database; 3. Use CREATETABLE to create a table, define fields and data types; 4. Use INSERTINTO to insert data, query data, update data by UPDATE, and delete data by DELETE. Only by mastering these steps, learning to deal with common problems and optimizing database performance can you use MySQL efficiently.

MySQL can't be installed after downloading MySQL can't be installed after downloading Apr 08, 2025 am 11:24 AM

The main reasons for MySQL installation failure are: 1. Permission issues, you need to run as an administrator or use the sudo command; 2. Dependencies are missing, and you need to install relevant development packages; 3. Port conflicts, you need to close the program that occupies port 3306 or modify the configuration file; 4. The installation package is corrupt, you need to download and verify the integrity; 5. The environment variable is incorrectly configured, and the environment variables must be correctly configured according to the operating system. Solve these problems and carefully check each step to successfully install MySQL.

MySQL download file is damaged and cannot be installed. Repair solution MySQL download file is damaged and cannot be installed. Repair solution Apr 08, 2025 am 11:21 AM

MySQL download file is corrupt, what should I do? Alas, if you download MySQL, you can encounter file corruption. It’s really not easy these days! This article will talk about how to solve this problem so that everyone can avoid detours. After reading it, you can not only repair the damaged MySQL installation package, but also have a deeper understanding of the download and installation process to avoid getting stuck in the future. Let’s first talk about why downloading files is damaged. There are many reasons for this. Network problems are the culprit. Interruption in the download process and instability in the network may lead to file corruption. There is also the problem with the download source itself. The server file itself is broken, and of course it is also broken when you download it. In addition, excessive "passionate" scanning of some antivirus software may also cause file corruption. Diagnostic problem: Determine if the file is really corrupt

Does mysql need the internet Does mysql need the internet Apr 08, 2025 pm 02:18 PM

MySQL can run without network connections for basic data storage and management. However, network connection is required for interaction with other systems, remote access, or using advanced features such as replication and clustering. Additionally, security measures (such as firewalls), performance optimization (choose the right network connection), and data backup are critical to connecting to the Internet.

How to optimize MySQL performance for high-load applications? How to optimize MySQL performance for high-load applications? Apr 08, 2025 pm 06:03 PM

MySQL database performance optimization guide In resource-intensive applications, MySQL database plays a crucial role and is responsible for managing massive transactions. However, as the scale of application expands, database performance bottlenecks often become a constraint. This article will explore a series of effective MySQL performance optimization strategies to ensure that your application remains efficient and responsive under high loads. We will combine actual cases to explain in-depth key technologies such as indexing, query optimization, database design and caching. 1. Database architecture design and optimized database architecture is the cornerstone of MySQL performance optimization. Here are some core principles: Selecting the right data type and selecting the smallest data type that meets the needs can not only save storage space, but also improve data processing speed.

Solutions to the service that cannot be started after MySQL installation Solutions to the service that cannot be started after MySQL installation Apr 08, 2025 am 11:18 AM

MySQL refused to start? Don’t panic, let’s check it out! Many friends found that the service could not be started after installing MySQL, and they were so anxious! Don’t worry, this article will take you to deal with it calmly and find out the mastermind behind it! After reading it, you can not only solve this problem, but also improve your understanding of MySQL services and your ideas for troubleshooting problems, and become a more powerful database administrator! The MySQL service failed to start, and there are many reasons, ranging from simple configuration errors to complex system problems. Let’s start with the most common aspects. Basic knowledge: A brief description of the service startup process MySQL service startup. Simply put, the operating system loads MySQL-related files and then starts the MySQL daemon. This involves configuration

How to optimize database performance after mysql installation How to optimize database performance after mysql installation Apr 08, 2025 am 11:36 AM

MySQL performance optimization needs to start from three aspects: installation configuration, indexing and query optimization, monitoring and tuning. 1. After installation, you need to adjust the my.cnf file according to the server configuration, such as the innodb_buffer_pool_size parameter, and close query_cache_size; 2. Create a suitable index to avoid excessive indexes, and optimize query statements, such as using the EXPLAIN command to analyze the execution plan; 3. Use MySQL's own monitoring tool (SHOWPROCESSLIST, SHOWSTATUS) to monitor the database health, and regularly back up and organize the database. Only by continuously optimizing these steps can the performance of MySQL database be improved.

See all articles