能力有限,以下代码写了一半,不想写了,,
有能力的大大们可以自行修正,
[Asm] 纯文本查看 复制代码 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[contains(text(),'下一页')]/@href")[0]
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() |