小编vpd*_*vpd的帖子

使用 Python requests 模块下载二进制文件

我需要从外部源下载文件,我使用基本身份验证登录到 URL

import requests
response = requests.get('<external url', auth=('<username>', '<password>'))
data = response.json()
html = data['list'][0]['attachments'][0]['url']
print (html)
data = requests.get('<API URL to download the attachment>', auth=('<username>', '<password>'), stream=True)
print (data.content) 
Run Code Online (Sandbox Code Playgroud)

我低于输出

<url to download the binary data> 
\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\xcb\x00\x00\x1e\x00\x1e\x00\xbe\x07\x00\x00.\xcf\x05\x00\x00\x00'
Run Code Online (Sandbox Code Playgroud)

我期待在同一会话中下载 word 文档的 URL。

python curl urllib2 python-requests

0
推荐指数
1
解决办法
3643
查看次数

标签 统计

curl ×1

python ×1

python-requests ×1

urllib2 ×1