INNER CODE UNIT · Python

write_log

ermaozi/get_subscribe · main.py:31

def write_log(content, level="INFO"):

    date_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    update_log = f"[{date_str}] [{level}] {content}\n"
    print(update_log, end="")
    Path("log").mkdir(exist_ok=True)
    with open(f'./log/{time.strftime("%Y-%m", time.localtime(time.time()))}-update.log', 'a', encoding="utf-8") as f:
        f.write(update_log)


def _extract_urls(summary):
    decoded = html.unescape(summary)
    urls = []
    for raw_url in re.findall(r"https?://[^\s\"'<>]+", decoded):
        url = raw_url.strip().rstrip('.,;)')
        if url not in urls:
            urls.append(url)
    return urls, decoded

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…