python - 如何正确访问 mendeley API?我无法获取文件的 document_id
问题描述
如何访问 mendeley API?( files.document_id
)
from mendeley import Mendeley
import requests
# I've changed the authentication details of my script (of course)
client_id = ****
client_secret = "**************"
redirect_uri = "********************"
mendeley = Mendeley(client_id, redirect_uri=redirect_uri)
auth = mendeley.start_implicit_grant_flow()
login_url = auth.get_login_url()
res = requests.post(login_url, allow_redirects=False, data={
'username': '**********',
'password': '**********'
})
auth_response = res.headers['Location']
session = auth.authenticate(auth_response)
lib = []
for f in session.files.iter():
try:
dic = {}
dic['filehash'] = f.filehash
dic['mime_type'] = f.mime_type
dic['file_name'] = f.file_name
dic['id'] = f.id
dic['size'] = f.size
dic['document_id'] = f.document_id # I can't access this one.
lib.append(dic)
except:
pass
lib 应该是一个字典列表。根据文档,它应该包含有关“document_id”的信息。(https://dev.mendeley.com/methods/#files)如果我尝试包含 document_id 结果为空。
解决方案
推荐阅读
- reactjs - 从数据库中检索信息后,信息未显示在屏幕上
- powershell - 有哪些不同的 Powershell 模块类型,它们是什么意思?
- python - pipenv 无法安装软件包
- c++ - 危险指针的内存排序
- cookies - 使用 'localhost:8000' 会发送 cookie 但 '127.0.0.1:8000' 不会?
- java - 更改项目中的值也会更改另一个项目 - RecyclerView Android
- angular - 我们如何防止在角度 8 中单击后退按钮时页面刷新?
- ruby-on-rails - Cloudinary 和 Rails:nil:NilClass 的未定义方法“上传”
- three.js - 有没有办法使用 THREE.JS 中的 PointerLock 控件来限制相机的旋转角度?
- c# - 当默认值是其他东西时,将 Texture2D 设置为“无”