我经常使用 mendeley 进行研究。我想为我的 mendeley 客户端目录中的文档编辑“用户标签”。具体来说,我想将期刊的声誉添加到这个领域(以 h 因子或影响因子的形式)。我已成功设置 OAuth2 身份验证,并且能够检索目录中的所有文档。但是我无法更改详细信息/将它们同步回来。
您知道 Mendeley API 是否可以做到这一点?
我在 API 的文档中没有找到像 set 或 sync 这样的方法。
from mendeley import Mendeley
# I've changed the authentication details of my script (of course)
client_id = ****
client_secret = "abcdefghijklmnop"
redirect_uri = "http://localhost:8080/someTest"
# These values should match the ones supplied when registering your application
mendeley = Mendeley(client_id, redirect_uri=redirect_uri)
auth = mendeley.start_implicit_grant_flow()
# The user needs to visit this URL, and log in to Mendeley.
login_url = auth.get_login_url()
res = requests.post(login_url, allow_redirects=False, data={
'username': 'mymail@myprovider.net',
'password': 'somePsasword?!'
})
auth_response = res.headers['Location']
# After logging in, the user will be redirected to a URL, auth_response.
session = auth.authenticate(auth_response)
# print(session.files.list().items)
for document in session.documents.iter(view='tags'):
print(document.title)
a = session.documents.get("5982d0ce-0425-3548-a063-519620c17886", view='tags')
a.tags = "TESTETETSETEST"
另一种选择是在我的 PC 上本地更改我的目录,但是我无法在我的 mendeley 目录中找到文件/数据库
编辑:
我已经通过将循环更改为以下内容来尝试 API 中提到的 update() 方法。暂时没有解决我的问题
for document in session.documents.iter(view='tags'):
print(document.tags)
document.tags = ["Test"]
document.update()