Browse Source

timeout, nlp except

David 10 years atrás
parent
commit
4b0b31ab64
1 changed files with 5 additions and 4 deletions
  1. 5 4
      news.py

+ 5 - 4
news.py

@@ -29,16 +29,17 @@ class News():
         self.SOURCE=source
         self.MATCHING_KW=[]
 
-        a = Article(url, language=lang,keep_article_html=True)
+        a = Article(url, language=lang,keep_article_html=True,request_timeout=10)
         try:
             a.download()
             a.parse()
-        except Exception:
-            print("ERROR parsing/downloading article")
+            a.nlp()
+        except Exception as e:
+            print("ERROR parsing/downloading/nlp article")
+            print(e)
             self.ERROR=True
             self.MATCHES=False
             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)])
         
         self.SCRAP_DATE=datetime.datetime.now()