尽管我认为
urls.txt文件仅包含url ,但这应该可以解决问题。不是
url:前缀。
import osimport urllibDOWNLOADS_DIR = '/python-downloader/downloaded'# For every line in the filefor url in open('urls.txt'): # Split on the rightmost / and take everything on the right side of that name = url.rsplit('/', 1)[-1] # Combine the name and the downloads directory to get the local filename filename = os.path.join(DOWNLOADS_DIR, name) # Download the file if it does not exist if not os.path.isfile(filename): urllib.urlretrieve(url, filename)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)