In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to realize the encryption process of Python crawler to master KuGou's music", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to achieve the Python crawler to master KuGou music encryption process"!
We enter the music we want to listen to on the search bar, and the editor enters: assassin.
Do you see a series of music and how to get some information about it? (the music information here refers to the hash value of the music and the album_id value of the music (these two parameters are used in the download link to get the music) and, of course, the name of the music. ]).
Since this series of music is loaded dynamically, that is, if you directly parse the data of this interface, you can't get it at all, so we should come to the following interface.
Can we see the music we just saw, and if we unfold one of the songs, we can find that all the information mentioned above seems to be available?
Let's take a look at the website of this request. It is found that this is a get request. The request data is as follows:
Xiaobian searched a number of songs and found that their request parameters have one thing in common, that is, except for the different values of keyword, clienttime, mid, uuid and signature, the others are almost the same. Clienttime originally means client time, its value is a timestamp, the value of mid and uuid is the same as clienttime, and the value of keyword is the keyword we search for. Now what we need is to figure out what the parameter value of signature is.
Editor got the length of this signature parameter value is 32, think it should be the use of encryption, some initial data, encrypt it, so how to get this initial data?
The editor clicked on all the js files on the site and found that the parameter value was under the js file.
Do you see the function md5! This should be the encryption function! And o.join ("") should be the initial data, o is a js array.
Now that you know how to get the value of o, how do you get it? Must be using breakpoints! We put the corresponding breakpoints around the signature, and then perform the breakpoint operation (this editor will not repeat them one by one, the editor is still a little foolish in using js breakpoints, so I will not mislead you here).
The above picture is the value in the js array o. After analyzing the data, it is found that most of these values are the parameter values of the URL we requested. What do the readers think?
The whole encryption algorithm is as follows:
This is too long! Originally, the editor interrupted to use python to simulate this encryption process, but now the editor sees that it is so long and gives up, but it does not mean that the encryption process cannot be realized. After consulting the data, the editor found that python can execute js statements. Do we only need to combine python and js to achieve this encryption? Let's do it!
The code is as follows:
Take a look at the results of the operation.
Is this the way to get the data we want? We only need to use json to parse the data, and we can get the two parameters mentioned above. [music hash value and music album_ id value]
3. Get the download link to the song
When we talk about music hash and music album_ id values in the second point above, why mention them both? Of course, it is to pave the way for the third point here. Ha!
The editor will not talk about this process in detail, because the focus of the editor today is this encryption ha!
We click on a song to play, and when we come to the above interface, we can see the download link of the song. The parameters of this request are as follows:
Do you see the two parameters I mentioned in these request parameters?
Through the analysis, it is found that the request can be successful only with the following three parameters. As follows
At this point, I believe that everyone on "how to achieve the Python crawler to master KuGou music encryption process" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.