get_catalogue¶
-
pyrcs.utils.
get_catalogue
(page_url, update=False, confirmation_required=True, json_it=True, verbose=False)[source]¶ Get the catalogue for a class.
- Parameters
page_url (str) – URL of the main page of a code category
update (bool) – whether to check on update and proceed to update the package data, defaults to
False
confirmation_required (bool) – whether to prompt a message for confirmation to proceed, defaults to
True
json_it (bool) – whether to save the catalogue as a .json file, defaults to
True
verbose (bool or int) – whether to print relevant information in console as the function runs, defaults to
False
- Returns
catalogue in the form {‘<title>’: ‘<URL>’}
- Return type
dict or None
Examples:
>>> from pyrcs.utils import get_catalogue >>> url = 'http://www.railwaycodes.org.uk/elrs/elr0.shtm' >>> catalog = get_catalogue(url) >>> type(catalog) <class 'dict'> >>> print(list(catalog.keys())[:5]) ['Introduction', 'A', 'B', 'C', 'D'] >>> url = 'http://www.railwaycodes.org.uk/linedatamenu.shtm' >>> catalog = get_catalogue(url) >>> print(list(catalog.keys())[:5]) ['Line data'] >>> line_data_catalog = catalog['Line data'] >>> type(line_data_catalog) <class 'dict'>