milu1123 发表于 2023-12-4 14:41

歌曲下载

能力有限,以下代码写了一半,不想写了,,
有能力的大大们可以自行修正,




import random
import time
from urllib.parse import urljoin
import requests
from lxml import etree

head = {
"Host": "www.22a5.com",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
}
head1 = {
    "Host": "www.22a5.com",
    "Origin": "http://www.22a5.com",
    "Referer": "http://www.22a5.com/mp3/3eckee3xc.html",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
    "X-Requested-With": "XMLHttpRequest"
    }

def shouye(url):
    resp = requests.get(url, headers=head)
    a = etree.HTML(resp.text)
    b = a.xpath("//div[@class='pic']/a/@href")
    for i in b:
      d = urljoin(url, i)
      print(d)
      xiayiye(d)

def xiayiye(d):
    resp = requests.get(d, headers=head)
    a = etree.HTML(resp.text)
    x = a.xpath("//div[@class='page']")
    time.sleep(random.randint(3, 6))
    for xi in x:
      xxx = xi.xpath("./a/@href")
      try:
            if xxx:
                x1 = urljoin(d, xxx)
                print(x1)
                xiayiye(x1)
      except Exception as e:
            print(e)

def xiazai():
    data = {
      'id': input("请输入歌曲ID"),
      'type': 'music'
    }
    url = 'http://www.22a5.com/js/play.php'
    resp = requests.post(url, data=data, headers=head1)
    print(resp.json()['title'], '\n', resp.json()['url'])

if __name__ == '__main__':
    url = 'http://www.22a5.com/'
    shouye(url)
    #xiazai()

xiaoxiaoyiyu 发表于 2024-1-18 10:41

Marken888 发表于 2023-12-4 14:57

先蹲一下爬虫大佬:lol

YIUA 发表于 2023-12-4 15:11

还没搞到音乐,稍等

adx123456 发表于 2023-12-4 15:19

还不如用异步

mini007.hi 发表于 2023-12-4 15:32

支持原创,谢谢!{:1_893:}

tvb318 发表于 2023-12-4 15:38

做个记号

缘小羽 发表于 2023-12-4 15:45

:eee好像才开始

2508hoho 发表于 2023-12-4 15:50

支持原创,蹲守大佬

milu1123 发表于 2023-12-4 16:02

adx123456 发表于 2023-12-4 15:19
还不如用异步

老大,,写个列子看看把,,

ShuyaoDong 发表于 2023-12-4 16:10

好下载,好网站,没用代码手动下载也不错
页: [1] 2 3 4 5
查看完整版本: 歌曲下载