check_site_connectivity#
- SurVigilance.ui.scrapers.check_site_connectivity(url=None, timeout=5)[source]#
Checks if a given URL or list of URLs is reachable by making a HEAD request.
Parameters#
- url: str or list, optional
The URL or list of URLs to check for connectivity. If None, SITES_TO_CHECK will be used. SITES_TO_CHECK = [”https://daen.tga.gov.au/medicines-search/”, “https://laegemiddelstyrelsen.dk/en/sideeffects/side-effects-of-medicines/interactive-adverse-drug-reaction-overviews/”, “https://fis.fda.gov/extensions/FPD-QDE-FAERS/FPD-QDE-FAERS.html”, “https://www.lareb.nl/en”, “https://www.medsafe.govt.nz/Projects/B1/ADRSearch.asp”, “https://vaers.hhs.gov/data/datasets.html”, “https://www.vigiaccess.org/”,]
- timeout: int, optional
The maximum time (in seconds) to wait for a connection. Defaults to 5 seconds.
Returns#
- tuple or list: If url is a string, returns a tuple containing:
bool: True if the site is reachable, False otherwise.
str: A message indicating the connectivity status.
If urls is a list, returns a list of these tuples.
Example#
>>> SITES_TO_CHECK = ["https://daen.tga.gov.au/medicines-search/", "https://laegemiddelstyrelsen.dk/en/sideeffects/side-effects-of-medicines/interactive-adverse-drug-reaction-overviews/", "https://fis.fda.gov/extensions/FPD-QDE-FAERS/FPD-QDE-FAERS.html", "https://www.lareb.nl/en", "https://www.medsafe.govt.nz/Projects/B1/ADRSearch.asp", "https://vaers.hhs.gov/data/datasets.html", "https://www.vigiaccess.org/",] >>> result, message = check_site_connectivity(url=SITES_TO_CHECK) >>> print(result)