Created
August 30, 2011 11:09
-
-
Save k1000/1180680 to your computer and use it in GitHub Desktop.
downlod urls from list in file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import os | |
IMG_DIR = "/Users/kamil/Desktop/PROJECTOS/webtenerife/scrap_actualidad-fr" | |
def download(url): | |
"""Copy the contents of a file from a given URL | |
to a local file. | |
""" | |
webFile = urllib.urlopen(url) | |
localPath = os.path.join(IMG_DIR, url.split("/")[-1:][0] ) | |
localFile = open(localPath, 'w') | |
localFile.write(webFile.read()) | |
webFile.close() | |
localFile.close() | |
return localPath | |
file_urls = "frances.txt" | |
urls = open(file_urls, "r") | |
for url in urls: | |
final_url = "http://%s" % url | |
print final_url | |
download(final_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment