I've been using newspaper library lately. The only issue I am finding is when I do article.publish_date
I am always getting None
.
class NewsArticle:
def __init__(self,url):
self.article = Article(url)
self.article.download()
self.article.parse()
self.article.nlp()
def getKeywords(self):
x = self.article.keywords
for i in range(0,len(x)):
x[i] = x[i].encode('ascii', 'ignore')
return x
return self.article.keywords
def getSummary(self):
return self.article.summary.encode('ascii', 'ignore')
def getAuthors(self):
x = self.article.authors
for i in range(0,len(x)):
x[i] = x[i].encode('ascii', 'ignore')
return x
def thumbnail_url(self):
return self.article.top_image.encode('ascii', 'ignore')
def date_made(self):
print self.article.publish_date
return self.article.publish_date
def get_videos(self):
x=self.article.movies
for i in range(0,len(x)):
x[i] = x[i].encode('ascii', 'ignore')
return x
def get_title(self):
return self.article.title.encode('ascii','ignore')
I'm going over a bunch of URLS. You can see I'm printing out the publish_date
before returning it.
I get as I said before:
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
All the other functions are working as intended. The documentation from the site looks at an example,
>>> article.publish_date
datetime.datetime(2013, 12, 30 0, 0)
I'm doing this I'm pretty sure. I'm not sure if someone had an eye to see my issue.