Skip to content

Search for WikiData entries using its REST API, parse the results to human-readable format.

License

Notifications You must be signed in to change notification settings

sedthh/awena-wikidata-crawler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Awena is a Python3 Wikidata search library that parses the returned Data type results to a human-readable format

The library uses the Wikidata JSON Rest Api to fetch data instead of querying its Query Service. No knowledge of SPARQL is necessary to use this tool. You can just keep iterating through relevant item ids instead.

Awena lets you search for names, labels, etc. and use their ids to load their information from the knowledge graph:

import awena

query		= 'Einstein'
crawler		= awena.Crawler('en') # set language of labels and descriptions
qid		= crawler.search(query)	# will return "Q937"
info		= crawler.load(qid)
print(info)
	
>>> {
>>>	'label': 'Albert Einstein', 
>>>	'description': 'German-born physicist and founder of the theory of relativity', 
>>>	'sex': 'male', 
>>>	'citizen': 'Q43287', 
>>>	'father': 'Q88665', 
>>>	'mother': 'Q4357787', 
>>>	'number_of_siblings': 1, 
>>>	'number_of_children': 3, 
>>>	'occupation': 'Q19350898', 
>>>	'date_of_birth': '+1879-03-14T00:00:00Z', 
>>>	'place_of_birth': 'Q3012', 
>>>	'date_of_death': '+1955-04-18T00:00:00Z', 
>>>	'place_of_death': 'Q138518', 
>>>	'cause_of_death': 'Q616003'
>>> }

Some values are also valid ids (letter Q followed by numbers), which you can use the same way to receive information about them:

citizen_of	= crawler.load(info["citizen"])
print(citizen_of)

>>> {
>>>	'label': 'German Empire', 
>>>	'description': 'empire in Central Europe between 1871–1918'
>>> }

Returned list of keys in dict depends on the information available on the topic.

About

Search for WikiData entries using its REST API, parse the results to human-readable format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages