get_last_updated_date¶
- pyrcs.parser.get_last_updated_date(url, parsed=True, as_date_type=False, verbose=False)[source]¶
Gets the last update date of a specified web page.
This function extracts the date when the given web page was last updated. The date can be returned as a string or a date object.
- Parameters:
url (str) – The URL of the web page for which the last update date is requested.
parsed (bool) – Whether to reformat the date into a standardized format (
YYYY-MM-DD
); defaults toTrue
.as_date_type (bool :param verbose: Whether to print relevant information to the console; defaults to
False
. :type verbose: bool | int) – IfTrue
, the date is returned as a datetime.date object; ifFalse
(default), it’s returned as a string.
- Returns:
The last update date of the specified web page, or
None
if this information is not available on the web page.- Return type:
str | datetime.date | None
Examples:
>>> from pyrcs.parser import get_last_updated_date >>> url_a = 'http://www.railwaycodes.org.uk/crs/CRSa.shtm' >>> last_upd_date = get_last_updated_date(url_a, parsed=True, as_date_type=False) >>> type(last_upd_date) str >>> last_upd_date = get_last_updated_date(url_a, parsed=True, as_date_type=True) >>> type(last_upd_date) datetime.date >>> ldm_url = 'http://www.railwaycodes.org.uk/linedatamenu.shtm' >>> last_upd_date = get_last_updated_date(url=ldm_url) >>> print(last_upd_date) None