Baidu MP3 design documentation:
(
2004-9-13
Renzhongfang @ nju.org.cn, rich input method programming, serial programming, network programming, website design, database programming experience, C, VC, Java, VB)
1, demand
Function: Search for content from Baidu (http://mp3.baidu.com/, and propose content (mainly URL address), mainly submit 2 functions void getlyric (String Songname, String Singername, String & Lyric); / / Get lyrics Requirements: When Singername is empty, accurately match the SongName search for Singername, do not properly match SingerName and SongName
Bool getMusicurl (Bool Test, String Singer, String & URL1, STRING & URL2, STRING & URL3); // Get Song Link Requirements: When Test is True, connect the URL to the connection test, require at least Two can connect to Test to false, do not connect to the connection test Enum musicType {AllMusic, MP3, RM, WMA, Flash}, respectively correspond to all music, MP3, RM, WMA, Flash, different types of Flash, respectively. Depending on the type of different, different URLs are taken as spaces, and the SongName's search is accurately matched. When SingerName is not available, the SingerName and SongName are accurately matched back to the return value: When entering SongName does not match the search MP3 name Returns false When you enter SongName to match the search MP3 name, return TRUE
Submit content: Source program and DEMO program, documentation
Request language: C , best use VC development, use Wininet or WinHTTP, do not use other HTTP Library
2, design ideas
Send an HTTP request from the BAIDUMP3 search engine to get the web content and extract the lyrics or song links.
Analysis 1, Baidu MP3 search HTTP request format:
Search "kiss":
Lyrics: http://mp3.baidu.com/m?tn=baidump3lyric&ct=150994944&rn=10&word= kiss battalion & lm = -1
Allmusic: http://mp3.baidu.com/m?rn=134217728&Word= kissed & lm = -1
MP3: http://mp3.baidu.com/m?tn=baidump3&ct=134217728&rn=134217728&rn= 0 = 0
RM: http://mp3.baidu.com/m?tn=baidump3&ct=134217728&rn=134217728&rn=1 = kiss
WMA: http://mp3.baidu.com/m?tn=baidump3&ct=134217728&rn= 2flash: http://mp3.baidu.com/m?tn=baidump3&ct=134217728&rn=134217728&rn=&word= kiss & lm = 6
Carefully analyze the above links will find that the request is divided into such paragraphs:
Http head: http://mp3.baidu.com/m?
Rn: 10 other empty when lyrics
TN: When checking the lyrics, it is baidump3lyric, and the song is Baidump3.
CT: When checking the lyrics 150994944, the song is 134217728
LM: Know the lyrics and check all songs to -1, MP3, RM, WMA, Flash correspond to 0, 1, 2, 6 respectively
Word: To query content
The values of RN, TN, and LM are constant, and the value of the CT is changing every day, and you need to get it first, check the source code of http://mp3.baidu.com/ Discovery as follows:
Function SYN (FORM)
{
IF (Form.LM [0] .checked) {
Form.rn.value = "10";
Form.tn.value = "baidump3lyric";
Form.ct.Value = "150994944";
} else {
IF (Form.LM [6] .checked) {
Form.tn.value = "baidump3ring";
Form.ct.Value = "285212672";
} else {
Form.tn.value = "baidump3";
Form.ct.Value = "134217728";
}
}
}
This will first extract the contents of the CT from http://mp3.baidu.com/ and then use to query, there are three types:
1. Analyze source code, build IF, ELSE binary tree,
2, find form.lm [0] .checked and form.lm [6] .Checked again
3, find form.tn.value = "xxxxxxx", then check the CT value near it
Nearby: After extracting the web source, find the form.tn.value position, find the location of the {, find the location of}, found Ct.Value in this content is the corresponding TN.Value corresponding.
These values are determined, and the HTTP request of the query can be constructed according to user query content.
After obtaining the source code content according to the HTTP request of the query content, lyrics and songs can be extracted, and the keywords are extracted as follows:
lyrics:
String lyrichead = "
String Lyrictail = "
";