You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import requests
from bs4 import BeautifulSoup
from SPARQLWrapper import SPARQLWrapper, JSON
def send_query_to_rotter(params):
url = 'https://www.rotter.se/gsi'
response = requests.get(url, params=params)
if response.status_code != 200:
raise Exception(f'Failed to retrieve the page: {response.status_code}')
return response.content
def send_query_to_wikidata(given_name, family_name, date_of_birth):
sparql = SPARQLWrapper("https://query.wikidata.org/sparql")
query = f"""
SELECT ?item WHERE {{
?item wdt:P735 wd:{given_name} ;
wdt:P734 wd:{family_name} ;
wdt:P569 "{date_of_birth}"^^xsd:dateTime .
}}
"""
sparql.setQuery(query)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
return results
# Rotter query parameters
rotter_params = {
'filter[fornamn]': 'Fritjof',
'filter[efternamn]': 'Thun',
'filter[fodelsedatum_param]': 'exakt',
'filter[fodelsedatum]': '1887-03-15',
# ... other parameters from the query string
}
# Wikidata identifiers for the name and date of birth
wikidata_given_name = 'Q123456' # Replace with the actual Wikidata item ID for the given name
wikidata_family_name = 'Q123456' # Replace with the actual Wikidata item ID for the family name
wikidata_date_of_birth = '1887-03-15T00:00:00Z' # Adjust format if necessary
# Send queries
rotter_html = send_query_to_rotter(rotter_params)
wikidata_results = send_query_to_wikidata(wikidata_given_name, wikidata_family_name, wikidata_date_of_birth)
# Process results
# ... (e.g., parse HTML with BeautifulSoup, compare results, etc.)
Originally posted by @salgo60 in #135 (comment)
The text was updated successfully, but these errors were encountered: