get_category_menu

pyrcs.parser.get_category_menu(url, update=False, confirmation_required=True, json_it=True, verbose=False)[source]

Gets a menu of the available classes from the specified URL.

This function scrapes a web page for available classes (typically categorised hyperlinks) and returns them as a dictionary. It also provides options to update the catalogue and save it as a JSON file.

Parameters:
  • url (str) – The URL of the menu page.

  • update (bool) – Whether to check for updates to the package data; defaults to False.

  • confirmation_required (bool) – Whether user confirmation is required before proceeding; defaults to True.

  • json_it (bool) – Whether to save the catalogue as a JSON file; defaults to True.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to False.

Returns:

A category menu in dictionary form, where keys are data cluster names and values are URLs.

Return type:

dict | None

Examples:

>>> from pyrcs.parser import get_category_menu
>>> menu = get_category_menu('http://www.railwaycodes.org.uk/linedatamenu.shtm')
>>> type(menu)
dict
>>> list(menu.keys())
['Line data']