Created
March 7, 2019 13:08
-
-
Save ettorerizza/cc3eb1cda5fa88c9bc938720bc18601a to your computer and use it in GitHub Desktop.
Search the Wikidata API like in the website searchbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| api = "https://www.wikidata.org/w/api.php" | |
| query = "some search" | |
| params = { | |
| 'action': 'query', | |
| 'list': 'search', | |
| 'format': 'json', | |
| 'srsearch': query, | |
| 'srprop': 'titlesnippet|snippet', | |
| 'srlimit': 100 | |
| } | |
| r = requests.get(api, params=params) | |
| print(r.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment