【发布时间】:2014-08-26 04:12:51
【问题描述】:
我正在尝试从网站下载所有 pdf 网址并将所有 pdf 附加到一个文件中。目前,我有一个包含 pdf 的所有 url 的列表。如何下载所有 pdf 并将它们附加在一起?我在下面附上了我的代码。我正在使用 Python 2.7.8。
# Download and merge pdfs
url_list = listofurl
for url in listofurl:
outfile = os.path.basename(url)
with open(outfile, 'w') as out:
out.write(urllib2.urlopen(url).read())
【问题讨论】:
-
您能否在示例代码中添加注释以显示错误发生的位置?
-
你能告诉我们跟踪信息吗?