Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skapa fråga gravstensinventeringen #163

Open
salgo60 opened this issue Oct 10, 2023 · 1 comment
Open

Skapa fråga gravstensinventeringen #163

salgo60 opened this issue Oct 10, 2023 · 1 comment

Comments

@salgo60
Copy link
Owner

salgo60 commented Oct 10, 2023

          Skapa fråga gravstensinventeringen

Originally posted by @salgo60 in #135 (comment)

@salgo60
Copy link
Owner Author

salgo60 commented Oct 10, 2023

Chat GPT

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant