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

Support crawling complete dossier with more than 1000 results #7

Open
mastaal opened this issue Feb 12, 2024 · 0 comments
Open

Support crawling complete dossier with more than 1000 results #7

mastaal opened this issue Feb 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mastaal
Copy link
Owner

mastaal commented Feb 12, 2024

def get_kamerstukken_in_kamerstukdossier(dossiernummer: str) -> list[tuple[str, str]]:
"""Using the SRU api, get all kamerstukken in a kamerstukdossier
Returns strings in the same formatting as denoted in other metadata, e.g. '35899;7', '35925-VII;31' or '35979;F'
"""
# overheid SRU documentation:
# https://data.overheid.nl/sites/default/files/dataset/d0cca537-44ea-48cf-9880-fa21e1a7058f/resources/Handleiding%2BSRU%2B2.0.pdf
base_query = f"https://repository.overheid.nl/sru?query=(w.dossiernummer=={dossiernummer})&maximumRecords=1000&startRecord=1"
try:
query_response = get_url_or_error(base_query)
except CrawlerException as exc:
logger.error("Received exception %s when trying to query the kamerstukken in dossier %s", exc, dossiernummer)
raise CrawlerException(f"Received exception when trying to query the kamerstukken in dossier {dossiernummer}") from exc
xml: ET.Element = ET.fromstring(query_response.text)
number_of_records = int(xml.find("{http://docs.oasis-open.org/ns/search-ws/sruResponse}numberOfRecords").text)
if number_of_records > 1000:
logger.critical("More than 1000 results in a kamerdossier!")
# TODO, implement this case

@mastaal mastaal added the bug Something isn't working label Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant