Skip to content

Instantly share code, notes, and snippets.

@k1000
Created August 30, 2011 11:09
Show Gist options
  • Save k1000/1180680 to your computer and use it in GitHub Desktop.
Save k1000/1180680 to your computer and use it in GitHub Desktop.
downlod urls from list in file
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