Mendeley API Python SDK文档的详细信息是否可以更改?

2024-04-30 01:22:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我经常用孟德尔做研究。我想编辑mendeley客户机目录中文档的“用户标签”。具体来说,我想把期刊的声誉添加到这个字段中(以h因子或影响因子的形式)。我已经成功地设置了OAuth2身份验证,并且能够检索目录中的所有文档。但是,我无法更改详细信息/将其同步回来。你知道吗

你知道门捷利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()

Tags: thetoin文档目录clientauthapi