|
@@ -24,24 +24,33 @@ class News():
|
|
|
MATCHING_KW=[]
|
|
MATCHING_KW=[]
|
|
|
TITLE=""
|
|
TITLE=""
|
|
|
|
|
|
|
|
- def __init__(self,url,sourceid, sourcename,kw,lang="en"):
|
|
|
|
|
|
|
+ def __init__(self,url,sourceid, sourcename,kw,lang="en",html=None):
|
|
|
url=sanitizeUrl(url)
|
|
url=sanitizeUrl(url)
|
|
|
self.URL=url
|
|
self.URL=url
|
|
|
self.SOURCENAME=sourcename
|
|
self.SOURCENAME=sourcename
|
|
|
self.SOURCE=sourceid
|
|
self.SOURCE=sourceid
|
|
|
self.MATCHING_KW=[]
|
|
self.MATCHING_KW=[]
|
|
|
|
|
|
|
|
- a = Article(url, language=lang,keep_article_html=True,request_timeout=10)
|
|
|
|
|
|
|
+ a=None
|
|
|
try:
|
|
try:
|
|
|
- a.download()
|
|
|
|
|
|
|
+ if html is None:
|
|
|
|
|
+ a = Article(url, language=lang,keep_article_html=True,request_timeout=10)
|
|
|
|
|
+ a.download()
|
|
|
|
|
+ else:
|
|
|
|
|
+ a= Article("")
|
|
|
|
|
+ a.set_html(html)
|
|
|
|
|
+
|
|
|
a.parse()
|
|
a.parse()
|
|
|
a.nlp()
|
|
a.nlp()
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
print("ERROR parsing/downloading/nlp article")
|
|
print("ERROR parsing/downloading/nlp article")
|
|
|
print(e)
|
|
print(e)
|
|
|
|
|
+ if html is not None:
|
|
|
|
|
+ print(len(html))
|
|
|
self.ERROR=True
|
|
self.ERROR=True
|
|
|
self.MATCHES=False
|
|
self.MATCHES=False
|
|
|
return
|
|
return
|
|
|
|
|
+
|
|
|
a.authors=self.dedup([self.fix_author(value) for value in a.authors if not self.isComment(value) and not self.isNoise(value)])
|
|
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()
|
|
self.SCRAP_DATE=datetime.datetime.now()
|