INNER CODE UNIT · Python

extract_links_from_readme

SuperAB123/Free-Official-Youtube-Content · Find broken links in the list.py:16

def extract_links_from_readme(path: str):
    with open(path, "r", encoding="utf-8") as f:
        return re.findall(r"https?://(?:www\.)?youtube\.com/[^\s)]+", f.read())

async def check_link(session: aiohttp.ClientSession, link: str) -> bool:
    try:
        async with session.get(link, allow_redirects=True, timeout=ClientTimeout(total=8)) as r:
            if r.status != 200:
                return False
            text = await r.text()
            return not any(p in text.lower() for p in BROKEN_PHRASES)
    except:
        return False

async def check_all(links: list[str], concurrency: int = 40):
    broken = []
    connector = aiohttp.TCPConnector(limit_per_host=concurrency, ssl=False)
    async with aiohttp.ClientSession(connector=connector) as session:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…