Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
1, in the use of selenium, we use selenium automation functions, and then extract the page where song_id, then use a third party outside the chain of conversion tool to convert, and then requests.get (url) where the acquisition by the converted url in AD, then open () function to write to a local, so that you can reach the resources of NetEase cloud music mp3 of the vip.
2, specific steps screenshot:
Convert url site: https://link.hhtjim.com/
import requests
from selenium import webdriver
import time
import uuid
if __name__ == "__main__":
browser = webdriver.Firefox()
browser.implicitly_wait(3)
browser.get("https://music.163.com/#/playlist?id=2409342460")
frame = browser.find_element_by_css_selector("#g_iframe")
browser.switch_to.frame(frame)
elements = browser.find_elements_by_css_selector("div.j-flag table.m-table tr td span.txt a ")
for e in elements:
id = str(e.get_attribute("href")).split("=")[-1]
name = e.find_element_by_css_selector("b").get_attribute("title")
url = "https://link.hhtjim.com/163/"+ id +".mp3"
result = requests.get(url)
print(url)
with open("D:/resources/music/" + name + ".mp3" , "wb") as fp:
fp.write(result.content)