python - Using urllib to Download -


im creating program download music. right of in selenium im trying s=change urllib im stuck @ download part. when run it works fine dont downloaded song

here code:

import urllib2, urllib, urllister import time selenium import webdriver 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()   url in parser.urls:     if "watch?v=" in url:          v = url          break   vid = ("youtube link %s"%v)  driver = webdriver.chrome() driver.get("youtube 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()  url in parser.urls:     if "/get?video_id" in url:          down = url  download_url = ("download link") urllib.urlretrieve(download_url) 

like said don't error message cant find downloaded song

as said in documentation:

urllib.urlretrieve return tuple (filename, headers) filename local file name under object can found

so try @ end of code:

download_url = ("download link") filename, headers = urllib.urlretrieve(download_url) print filename 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -