我正在创建一个下载音乐的程序。现在其中一些在 selenium 中,但我试图慢慢地 s=将其完全更改为 urllib,但我停留在下载部分。当我运行它时它工作正常,但我没有得到下载的歌曲
这是我的代码:
import urllib2, urllib, urllister
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
raw_i=raw_input("Search: ")
x = urllib.quote_plus(raw_i)
site1 = urllib2.urlopen(' Youtube Search Link ')
y = site1.read()
parser = urllister.URLLister()
parser.feed(y)
parser.close()
for url in parser.urls:
if "watch?v=" in url:
v = url
break
vid = ("youtube link %s"%v)
driver = webdriver.Chrome()
driver.get("Youtube to Mp3 link")
elem = driver.find_element_by_id("youtube-url")
elem.clear()
elem.send_keys(vid)
elem.send_keys(Keys.RETURN)
time.sleep(5)
download = driver.page_source
parser = urllister.URLLister()
parser.feed(download)
parser.close
driver.quit()
for url in parser.urls:
if "/get?video_id" in url:
down = url
download_url = ("Download link")
urllib.urlretrieve(download_url)
就像我说的,我没有收到错误消息,但我找不到下载的歌曲