The Baidu new song list and the Hot song list downloader which realizes with the python

Source: Internet
Author: User

First of all, this tool is only used for learning, does not involve copyright issues, because the songs inside the Baidu music itself can be downloaded, and now Baidu also provides a "Baidu music player", you can download the bulk of this tool.

I did this tool at the time, Baidu has not provided "Baidu music player", and I want to bulk download, so I did such a download tool. Of course, mainly for learning.

Tools are developed using PYTHON2.7.3+PYQT.

Function:

1. To display Baidu new song list or hot song list can download the song list.

2. Support the download of single and multiple songs.

3. Can copy all the links in the song list, convenient in the Thunderbolt and other download tools to create the download group.

Defects:

At present, the use of single threaded, inefficient, UI interface is easy to suspend animation.

The tool runs the process:

1. Analog User login Baidu.

2. If the login is successful, collect and parse the page content, load the song single list.

3. Download the song after the user clicks on the download button or the bulk download button.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

How to use:

1. At the end of the configuration file setting.py, the configuration can login Baidu's account and password, and Baidu hot song list or the URL of the new song list.

Username = "Your Baidu acount"    #配置你的百度账号  
password = "Your Baidu password"  #配置你的百度密码  
      
musiclisturl = "http ://music.baidu.com/top/dayhot "  #   Http://music.baidu.com/top/new

2. Run the mainwindow.py file directly, if the speed does not give the power may have to wait 3, 4 minutes.

After running as shown:

The knowledge used:

1. First use of PYQT GUI programming, form layout and Qtablewidget, Qprogressbar, Qpushbutton and other controls and control overrides

2. Use of the network programming part of the content, using Urllib,urllib2,cookielib request Web page, analog login Baidu.

3. Use Htmlparser to parse Web content and match page elements.

4. Use codecs to read and write documents.

The problems encountered:

1. Coding problems, because the file encoding is set to UTF-8 when the file is created, the encoding problem is always prompted when the content written to the file is non-ASCII content, such as Chinese. In fact, Baidu Music Web pages are all UTF-8 format, so the content obtained from the Web page is also UTF-8 format, but to write content written in UTF-8 text, the content of the Web page must be decode ("UTF8") decoded to Unicode format in order to write correctly.

Detection content encoding, you can use the Chardet module of the Chardet.detect ("content") method.

In addition, Htmlparser parsing Web page content process, some download page will appear the problem, according to the hint information discovery or coding problem, the feed () method in the content parameters decode ("UTF8"), the result is normal.

Decode decodes content to Unicode type based on parameter content, depending on the encoding of the page being collected.

GitHub Download Address: Click here

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.