Browse Source

fix parser and load <a make image fail

weichen 3 years ago
parent
commit
080a689d12
2 changed files with 2 additions and 2 deletions
  1. 1 1
      models/manages/routes.py
  2. 1 1
      models/utils/parsers.py

+ 1 - 1
models/manages/routes.py

@@ -21,7 +21,7 @@ class RequiredData():
         if '<b' in text:
             soup = BeautifulSoup(text, "html.parser")
             section_data.setdefault('b', []).append(soup.b.string)
-        elif '<a ' in text:
+        elif '<a ' in text and '</a>' in text:
             soup = BeautifulSoup(text, "html.parser")
             section_data.setdefault('a', []).append(soup.a.string)
         elif '<p' in text:

+ 1 - 1
models/utils/parsers.py

@@ -35,7 +35,7 @@ class SectionParser():
                 soup.p.string = self.update_data.get('p', [''])[self.p_order]
                 text = self._get_spaces(text) + str(soup)
                 self.p_order += 1
-            elif '<a ' in text:
+            elif '<a ' in text and '</a>' in text:
                 soup = BeautifulSoup(text, "html.parser")
                 soup.a.string = self.update_data.get('a', [''])[self.a_order]
                 text = self._get_spaces(text) + str(soup)