First, as an online music player, you need to use the front-end and database.
On the database side, we have no way to produce, first of all, the issue of copyright, plus the amount of data. So we need to borrow databases from other network players.
But these online players, such as Baidu, cool dog, cool and other online music players, is not to provide their database interface, so this we need to crawl these online music player interface, first of all, this thing is a violation. is a violation of the copyrights of these companies. Therefore, cannot be used for commercial purposes
We use cool dog music as an example to crawl the API interface of his connected database
I am using Google to go into private mode, because in this mode, songs are not cached
1. Go to the cool dog's official website www.kugou.com and then open a song at random.
The window above will appear
F12 to open the debugger tool
Refresh the page, and then record the page transfer information in the network
Then we will find that in the record, there is one data that is the longest loading time. This data is the largest amount of data in the page, that is, the song
Filter data type Multimedia
Then I find the music in the list
To view the music header, you will find the address of the song,
We open this address in a new window.
It's going to be a song.
That's when we can query a song and add it to the list
At this point we look at the latest loaded data in the developer tools
Viewing this data will reveal some text that is loaded in addition to the song
Looking at the head of these texts, it is found that a parameter callback is passed inside. This is the callback function, which is used for JSON passing, is the common way to pass the data. But this is usually not safe, so the song is generally not here.
Then we will find a page that is passed to the PHP
View Content
Here we will find the lyrics address, and song name, lyrics, and a hash value to view the request address.
Here we can see that the Web page sends a hash of the data to the database. We know that this hash value is the unique encoding of the song in the database
Next, we just need to know the hash value of the song, we can find the song address.
Open the search list again, use the developer tools to intercept the data, filter JS, and you will find such data.
Just open one of these lists and we'll see that there's a filehash value in it that duplicates this value.
And we replace the previous search for the song, find the PHP file, and replace the hash value
This time the page will return a JSON file
We can format this JSON using the online JSON parser.
There's a play_url parameter, and the value inside is an address.
We can open this address in a new window.
Here we find open a familiar window, a MP3,
We view the request address of the lyrics list
This will have a keyword parameter, followed by garbled, but this is a Chinese transcoding method, copy the request address, and change the value of this keyword.
The result of the return is a JSON file that we can format
When we look at it, we can actually see that it's actually a song of the keyword that we set up for the search.
There'll be a lot of songs in there.
We found the filehash of one of the songs.
Using the same method as before, you can get the MP3 address of this song,
Thus we obtained the two URL request address, the first is the song query list, you can get the hash value of the song, the second is the address of the song, can be based on a query list of hash value to get the address of the song
http://songsearch.kugou.com/song_search_v2?callback=jquery191034642999175022426_1489023388639&keyword={ Song name}&page=1&pagesize=30&userid=-1&clientver=&platform=webfilter&tag=em&filter=2 &iscorrection=1&privilege_filter=0&_=1489023388641
http://www.kugou.com/yy/index.php?r=play/getdata&hash={Song Hash Value}
Online music player-----Cool Dog Music API interface Crawl