爬虫批量下载DJ娱乐网串烧大赛获奖歌曲

爬虫批量下载DJ娱乐网串烧大赛获奖歌曲

调用的解析接口分享在下面

import requests
from lxml import etree
import re
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
    'Connection': 'keep-alive'
}
def get_DjIdName():
    start_urls = ['http://www.djyule.com/dasai/index.htm',
                  'http://www.djyule.com/dasai/index_2.htm',
                  'http://www.djyule.com/dasai/index_3.htm',
                  'http://www.djyule.com/dasai/index_4.htm',
                  'http://www.djyule.com/dasai/index_5.htm',
                  'http://www.djyule.com/dasai/index_6.htm',
                  ]
    for start_url in start_urls:
        response = requests.get(start_url, headers=headers)
        text = response.content.decode('utf-8')
        html = etree.HTML(text)
        DJnamelink = html.xpath('//div[@class="DJnameLink"]')
        for dj in DJnamelink:
            dj_id = dj.xpath('./a/@href')[0]
            dj_id = re.sub(r'\D', '', dj_id)
            dj_name = dj.xpath('./a/text()')[0]
            download_url = get_DjDownload_url(dj_id)
            print(dj_name)
            r = requests.get(download_url, headers=headers)
            with open(r'C:\Users\wanrenmiyouxi\Music\{}.mp3'.format(dj_name), "wb+") as f:
                f.write(r.content)
def get_DjDownload_url(dj_id):
    jiexi_url = 'http://aang.xyz/jx/djyule.php?id={}'.format(dj_id)
    response = requests.get(jiexi_url, headers=headers)
    download_url = response.url
    return download_url
if __name__ == '__main__':
    get_DjIdName()

接口是在某某某网站偷的在此分享给大家

www.djyule.com

DJ娱乐网 100万首超高清DJ舞曲带你嗨,车载音乐,电音,MC喊麦现场,劲爆Dj,重低音DJ,夜店Disco

解析的是mp3格式的

http://aang.xyz/jx/djyule.php?id=歌曲IP

如:http://aang.xyz/jx/djyule.php?id=380992

下载的时候第31行的路径改为你自己的下载路径C:\Users\13164\Music\

这个接口解析的不是无损的320kbps码率 是试听的60kbps码率 这个在网络Network里可以找到 不需要调用这个接口 算了 省事了

万人迷游戏
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: