我想从给定的链接中检索 pdf 文件。命令行输出显示文件已保存在指定位置
import os
myPath = 'C:\\Documents'
filename = 'test1.pdf'
url = 'http://www.ha.org.hk/visitor/ha_view_content.asp?content_id=253124&lang=ENG'
fullfilename = os.path.join(myPath, filename)
urlretrieve(url, fullfilename)
>>> ('C:\\Documents\\test1.pdf', <http.client.HTTPMessage object at 0x016E0BB0>)
但是,当我转到文件目录时,test1.pdf 看起来已损坏。
下载的文件大小只有 1 KB,但实际文件应该在 4MB 左右。