马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
为什么我的xpath解析出来的是空列表啊? from selenium import webdriver
from lxml import etree
import os
bro = webdriver.Chrome(executable_path="./chromedriver.exe")
url = "https://music.163.com/m/playlist?id=6731975194"
bro.get(url)
page_text = bro.page_source
tree = etree.HTML(page_text)
tr_list = tree.xpath('//*[@id="auto-id-TEZk3fbkwpQOcPlD"]/table//tr')
if not os.path.exists("./wangyi list music"):
os.mkdir("./wangyi list music")
try:
for id_ in id_list:
id_ = id_.split('=')[-1]
name = name_list[i]
i +=1
base_url = "http://music.163.com/song/media/outer/url?id=%s.mp3" % id_
content = req.get(url=base_url+id_,headers=headers).content
with open("./wangyi list music/"+name+".mp3",'wb') as fp:
fp.write(content)
print(name+".mp3下载完成!")
except FileNotFoundError or OSError:
print(name+"因出错没有下载")
|