Use Python to download HD music videos of NetEase Cloud Music

Source: Internet
Author: User
This article will share with you the idea of downloading the HD music video code of NetEase Cloud Music in Python. I am a newbie and have not done any special functions. I just loop through the id of the music video directly, you can expand it on your own. Python downloads the high-definition music videos of NetEase Cloud Music. it does not go into the analysis from the home page and loops directly ....

DownPage1.py

The code is as follows:


# Coding = UTF-8
Import urllib
Import re
Import OS
Def getHtml (url ):
Page = urllib. urlopen (url)
Html = page. read ()
Return html
Def getVideo (html ):
Reg = r'hurl = (. +? \. Jpg )'
Imgre = re. compile (reg)
Imglist = re. findall (imgre, html)
Return imglist
For num in range (28000,000000 ):
Print num
Html = getHtml ("http://music.163.com/mv? Id = % s "% num)
Parsed = getVideo (html)
If len (parsed) = 0:
Continue
VedioUrls = parsed [0]. split ("&")
Artist = vedioUrls [4]. split ("=") [1]. decode ('utf-8'). strip ()
Song = vedioUrls [3]. split ("=") [1]. decode ('utf-8'). strip ()
If len (vedioUrls [0]) = 0:
Continue
Filename = '% s/%s.mp4' % (artist, song)
If "/" in song:
Continue
If OS. path. exists (filename ):
Print 'The MV file exists. % s' % num
Else:
Print 'The MV is downloding. % s' % num
If OS. path. exists (artist ):
Print ""
Else:
OS. makedirs (artist)
Urllib. urlretrieve (vedioUrls [0], filename)

The above is all the code shared in this article. I hope you will like it.

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.