From b3c7e297c415ff59915715d58d5e8cb07dec92b4 Mon Sep 17 00:00:00 2001 From: Meekdai Date: Tue, 28 May 2024 22:15:49 +0800 Subject: [PATCH] Update Gmeek.py --- Gmeek.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Gmeek.py b/Gmeek.py index 9ba26ab..74803dd 100644 --- a/Gmeek.py +++ b/Gmeek.py @@ -8,6 +8,7 @@ import shutil import urllib import requests import argparse +from bs4 import BeautifulSoup from github import Github from xpinyin import Pinyin from feedgen.feed import FeedGenerator @@ -159,8 +160,12 @@ class GMEEK(): ) if 'Gmeek-html' in post_body: - pattern = r'Gmeek-html>(.*?)' - post_body=re.sub(pattern, r'\1', post_body) + soup = BeautifulSoup(post_body, "html.parser") + code_tags = soup.find_all("code", class_="notranslate") + for code_tag in code_tags: + if code_tag.text.startswith("Gmeek-html"): + code_tag.replace_with(code_tag.text.replace("Gmeek-html", "").strip()) + post_body=str(soup) postBase["postTitle"]=issue["postTitle"] postBase["postUrl"]=self.blogBase["homeUrl"]+"/"+issue["postUrl"]