How to get the entity's "instance of" item?
JiyaoWei opened this issue · 1 comments
JiyaoWei commented
How to get the entity's "instance of" item?
for example, Barack Obama is human's instance.
siznax commented
Hi @JiyaoWei. Thanks for opening this issue. We put the value of the 'instance of (P31)' label in the "what" data item...
>>> page = wptools.page("Barack Obama")
>>> page.get_wikidata()
Barack Obama (en) data
{
WARNINGS: <dict(1)> main
aliases: <list(11)> Barack Hussein Obama II, Barack Obama II, Ba...
claims: <dict(304)> P31, P21, P27, P569, P19, P735, P25, P22, P2...
description: 44th president of the United States from 2009 to 2017
image: <list(1)> {'file': 'File:President Barack Obama.jpg', 'ki...
label: Barack Obama
labels: <dict(435)> P1005, P10632, P5558, Q12201445, P103, Q6859...
modified: <dict(1)> wikidata
requests: <list(11)> wikidata, labels, labels, labels, labels, l...
title: Barack_Obama
what: human
wikibase: Q76
wikidata: <dict(303)> instance of (P31), sex or gender (P21), co...
wikidata_pageid: 205
wikidata_url: https://www.wikidata.org/wiki/Q76
}
<wptools.page.WPToolsPage object at 0x10c2b7f10>
>>> page.data['what']
'human'