downloading an excel file from the web in python

后端 未结 4 1669
闹比i
闹比i 2020-12-05 09:00

I have the following web address:

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

I tried to download the file:

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 09:22

    I suggest using requests:

    import requests
    dls = "http://www.muellerindustries.com/uploads/pdf/UW SPD0114.xls"
    resp = requests.get(dls)
    
    output = open('test.xls', 'wb')
    output.write(resp.content)
    output.close()
    

    To get requests installed:

    pip install requests
    

提交回复
热议问题