如何使用urllib下载多个文件?

2024-04-25 13:53:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道如何通过将urllib指向特定文件来下载1个文件。在

如何下载url中的所有文件?其中包含的链接

#Code to download 1 file, which im using at the moment
import urllib, os
    os.chdir('/directory/to/save/the/file/to')
    url = 'http://urltosite/myfile.txt'#Download all files in this url
    urllib.urlretrieve(url)

Tags: 文件thetourlwhichos链接download