David 10 tahun lalu
induk
melakukan
1c22b37ba1
2 mengubah file dengan 4 tambahan dan 1 penghapusan
  1. 3 1
      news.py
  2. 1 0
      parser.py

+ 3 - 1
news.py

@@ -35,7 +35,7 @@ class News():
             a.parse()
         except Exception:
             print("ERROR parsing/downloading article")
-            ERROR=True
+            self.ERROR=True
             return
         a.nlp()
         a.authors=self.dedup([self.fix_author(value) for value in a.authors if not self.isComment(value) and not self.isNoise(value)])
@@ -47,6 +47,7 @@ class News():
         self.TEXT=a.text
         self.TITLE=a.title
         self.HTML=htmlmin.minify(a.article_html,remove_empty_space=True)
+        self.ERROR=False
         lowertext=self.TEXT.lower()
         for k in kw:
             #if re.match(k["pattern"], self.TEXT): #FIXME regex vs string in string
@@ -69,6 +70,7 @@ class News():
                 "weight": self.WEIGHT_SUM,
                 "kw": self.MATCHING_KW,
                 "html": self.HTML, 
+                "error": self.ERROR,
                 "title": self.TITLE
                 }
 

+ 1 - 0
parser.py

@@ -55,6 +55,7 @@ def news_worker(source_id,kw):
 
 q=Queue()
 d=db()
+d.purge_error()
 num_worker_threads=100
 for s in d.sources():
     parseSource(s)