-
-
Save cmj/a17670f111d88ea98fb25de226eb6235 to your computer and use it in GitHub Desktop.
Print top 15 services reported from downdetector.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Print services/sites that are reporting issues via downdetector.com | |
| # - pip install curl_cffi | |
| # ex: Verizon • Spectrum • Google Fiber • Cox • OpenAI • AT&T • T-Mobile • YouTube • Wyyerd Fiber • X (Twitter) • Xfinity by Comcast • Roblox • TDS Telecom• Steam • Google | |
| import sys | |
| from bs4 import BeautifulSoup | |
| from curl_cffi import requests | |
| URL = "https://downdetector.com" | |
| MAX_SITES = 15 | |
| def fetch_page(url): | |
| try: | |
| response = requests.get(url, impersonate="chrome120", timeout=10) | |
| response.raise_for_status() | |
| return response.content | |
| except Exception as e: | |
| sys.exit(f"Error fetching {url}: {e}") | |
| def parse_sites(html): | |
| soup = BeautifulSoup(html, "html.parser") | |
| container = soup.find(class_="contents") | |
| if not container: | |
| return [] | |
| sites = container.find_all("div", class_="py-2") | |
| names = [] | |
| for site in sites[:MAX_SITES]: | |
| header = site.find("h2") | |
| if header: | |
| names.append(header.get_text(strip=True)) | |
| return names | |
| def main(): | |
| html = fetch_page(URL) | |
| site_names = parse_sites(html) | |
| print(" • ".join(site_names)) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment