def find_links(text):
    import re
    import requests

    from web_ui import app

    # Everything that looks remotely like a URL
    expr = "(https?://[\S]+)"
    rv = list()

    candidates = re.findall(expr, text)

    if candidates:
        for c in candidates:
            app.logger.info("Testing potential link '{}' for availability".format(c))
            try:
                res = requests.head(c, timeout=15.0)
            except requests.exceptions.RequestException:
                pass
            else:
                if res and res.status_code < 400:
                    rv.append(res)
                    text = text.replace(c, "")
    return (rv, text)
Given a text, find all alive links inside
dataset/ETHPy150Open ciex/souma/web_ui/helpers.py/find_links