【问题标题】:Mendeley API - Python SDK - Change Details of a Document possible?Mendeley API - Python SDK - 可以更改文档的详细信息吗?
【发布时间】:2019-06-16 20:45:30
【问题描述】:

我在研究中经常使用 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()

【问题讨论】:

    标签: python api sdk mendeley


    【解决方案1】:

    我对 Mendeley Python SDK 并不熟悉,但我觉得很奇怪,您在 a.tags = "TESTETETSETEST" 之后不需要进行其他调用。

    你不需要使用update方法吗?

    【讨论】:

    • 但是显然并没有改变细节,因为当我再次运行脚本时 print(document.tags) 仍然为所有文档返回 None 。 API Doc 声明“更新此文档”。它还返回更新的文档。我是否仍然需要同步/更新会话?
    • 我认为update 方法需要一些参数。大概是您打算更新的字段。恐怕我没有太多 Python 知识,所以帮不上什么忙
    • NW 我非常感谢在这一点上能得到任何帮助。尽管如此,我认为真正的 Mendeley API 委员会会对社区有所帮助。我尝试使用 document.update("tags") 导致 TypeError: update() 接受 1 个位置参数,但给出了 2 个
    • 使用类时通常会出现此错误,但此示例不使用类
    猜你喜欢
    • 2015-10-04
    • 2014-03-01
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    • 2013-03-16
    • 2011-07-28
    • 2010-11-11
    • 1970-01-01
    相关资源
    最近更新 更多