英文:
How to make the value of a claim in wikidata a hyperlink or link to another external page
问题
我正在尝试在Wikidata中创建一个脚本,用于为特定实体创建声明。该声明应具有一个属性,名称为“外部标识符”,以及一个值,该值是外部组织生成的标识符。此外,我希望该值是一个超链接,当用户单击时将其重定向到该组织的页面。
为了澄清,我希望将变量“objectIdentifier”显示为文本,但在单击时将其重定向到“redirectURL”,即组织的页面。该标识符是字母数字代码,但我目前无法使用当前的函数将其变成超链接。
以下是我正在使用的创建声明的函数:
def writeStatement(apiUrl, editToken, subjectQNumber, propertyPNumber, objectIdentifier, redirectURL):
parameters = {
'action': 'wbcreateclaim',
'format': 'json',
'entity': subjectQNumber,
'snaktype': 'value',
'bot': '1',
'token': editToken,
'property': propertyPNumber,
'value': '"' + objectIdentifier + '"',
'url': redirectURL
}
r = session.post(apiUrl, data=parameters)
data = r.json()
return data
然而,当前的函数只将标识符写入为纯文本,而不创建超链接。
英文:
I am trying to create a script in Wikidata that creates a claim for certain entities. The claim should have a property of "external identifier" and a value that is the identifier generated by an external organization. Additionally, I want the value to be a hyperlink that directs the user to the organization's page when clicked.
To clarify, I want the variable "objectIdentifier" to be displayed as text, but when clicked, it should redirect to "redirectURL", the organization's page. The identifier is an alphanumeric code, and I am currently unable to make it into a hyperlink using my current function.
Here is the function I am using to create the claim:
def writeStatement(apiUrl, editToken, subjectQNumber, propertyPNumber, objectIdentifier, redirectURL):
parameters = {
'action': 'wbcreateclaim',
'format': 'json',
'entity': subjectQNumber,
'snaktype': 'value',
'bot': '1',
'token': editToken,
'property': propertyPNumber,
'value': '"' + objectIdentifier + '"',
'url': redirectURL
}
r = session.post(apiUrl, data=parameters)
data = r.json()
return data
However, the function currently only writes the identifier as plain text without creating a hyperlink.
答案1
得分: 0
在属性上设置格式化程序 URL可能是所需的全部。
英文:
Setting a formatter URL on the property might be all that’s needed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论