在python中从网络下载Excel文件

蔬菜

我有以下网址:

dls = "http://www.muellerindustries.com/uploads/pdf/UW SPD0114.xls"

我尝试下载文件:

urllib2.urlopen(dls, "test.xls")

这产生了一个名为“ test.xls”的文件,但这显然是一个html文件。如果我在firefox中打开了html文件,则打开了一个excel文件,但是如果我在excel中打开了文件,那绝对不是我要找的excel文件。

如果我有一个与上述地址相同的网址,我如何使python将excel文件下载为excel文件?

耶利米

这会将excel文件保存在运行脚本的文件夹中。

import urllib
dls = "http://www.muellerindustries.com/uploads/pdf/UW SPD0114.xls"
urllib.request.urlretrieve(dls, "test.xls")  # For Python 3
# urllib.urlretrieve(dls, "test.xls")  # For Python 2

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章