我正在编写一个下载音乐的程序,我试图将其完全更改为 urllib2,但我似乎无法获得将 url 信息输入下载站点的部分
这是我的代码:
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 Serch URL')
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 = ("Video URL")
driver = webdriver.Chrome()
driver.get("Youtube to Mp3 Site URL")
elem = driver.find_element_by_id("youtube-url")
elem.clear() #This Bit I want in urllib
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 URL")
filename, headers = urllib.urlretrieve(download_url, 'Download.mp3')
一切正常,但我似乎无法让 selenium 部分成为 urllib 我只需要清除提交表单然后输入视频 url 然后按 enter 或单击转换按钮
请帮忙!!