Created
June 17, 2020 08:25
-
-
Save salgo60/b6664b2aa4b6b7d613374db2f02a5314 to your computer and use it in GitHub Desktop.
This file contains 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 pandas as pd | |
import pprint | |
import os | |
from wikidataintegrator import wdi_core, wdi_login | |
mediawiki_api_url = "https://swebase.wiki.opencura.com/w/api.php" # <- change to applicable wikibase | |
sparql_endpoint_url = "https://swebase.wiki.opencura.com//query/sparql" # <- change to applicable wikibase | |
if "SWEBASEUSER" in os.environ and "SWEBASEPASS" in os.environ: | |
WBUSER = os.environ['SWEBASEUSER'] | |
WBPASS = os.environ['SWEBASEPASS'] | |
else: | |
raise ValueError("SWEBASEUSER and SWEBASEPASS must be specified in local.py or as environment variables") | |
login = wdi_login.WDLogin(WBUSER, WBPASS, mediawiki_api_url=mediawiki_api_url) | |
print("=Look at current content in SWEBASE....") | |
query = """ | |
PREFIX wdt: <https://swebase.wiki.opencura.com/prop/direct/> | |
SELECT DISTINCT ?s ?p ?o WHERE { | |
?s ?p ?o } | |
""" | |
results = wdi_core.WDItemEngine.execute_sparql_query(query, endpoint=sparql_endpoint_url) | |
for result in results["results"]["bindings"]: | |
#pprint.pprint(result) | |
pprint.pprint(result["s"]["value"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Verkar funka output
/usr/local/bin/python3.8 /Users/magnus/Library/Preferences/PyCharmCE2019.2/scratches/scratch_86.py
https://swebase.wiki.opencura.com/w/api.php
Successfully logged in as Salgo60
=Look at current content in SWEBASE....
'http://swebase.wiki.opencura.com/entity/Q1'
'http://swebase.wiki.opencura.com/entity/Q1'
'http://swebase.wiki.opencura.com/entity/Q1'