我试图使用 atlassian 和请求模块从我的 Confluence 页面下载一个文件。但是,尽管我提供了有效的用户名和密码,但它给了我 401
我的代码
from atlassian import Confluence
import requests
confluence = Confluence(
url="https://kittu-demo123.atlassian.net",
username='username',
password='password')
print('hello')
attachments_container = confluence.get_attachments_from_content(page_id=98312, start=0, limit=500)
attachments = attachments_container['results']
for attachment in attachments:
fname = attachment['title']
download_link = confluence.url + attachment['_links']['download']
r = requests.get(download_link, auth=(confluence.username, confluence.password))
if r.status_code == 200:
with open(fname, "wb") as f:
for bits in r.iter_content():
f.write(bits)