From 17055b25e9ad77af1b2722cae12ce677050ef956 Mon Sep 17 00:00:00 2001 From: ZouJiu <1069679911@qq.com> Date: Sat, 21 Oct 2023 21:45:55 +0800 Subject: [PATCH] formula remove space --- crawler.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crawler.py b/crawler.py index 2d5c2bb..419ac6c 100644 --- a/crawler.py +++ b/crawler.py @@ -345,10 +345,16 @@ def parser_beautiful(innerHTML, article, number, dircrea, bk=False): if 'class' in chi.attrs.keys(): classc = chi.attrs["class"] if datatex and classc and 'ztext-math' in classc: - if article[-3-1:]=='
' or article[-1:]=='\n': - article += "\n$" + chi.attrs["data-tex"] + "$" - else: - article += "$" + chi.attrs["data-tex"] + "$" + content = chi.attrs["data-tex"] + while len(content) > 0 and ' '==content[0]: + content = content[1:] + while len(content) > 0 and ' '==content[-1]: + content = content[:-1] + if len(content) > 0: + if article[-3-1:]=='
' or article[-1:]=='\n': + article += "\n$" + content + "$" + else: + article += "$" + content + "$" else: article, number = parser_beautiful(chi, article, number, dircrea, bk) # article += nod.text