最近は新聞図書館をよく利用しています。私が見つけている唯一の問題は、いつarticle.publish_date
私が常に得ているかということです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')
たくさんの URL を調べています。publish_date
返却する前にを印刷していることがわかります。
前に言ったように取得します:
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
他のすべての機能は意図したとおりに機能しています。サイトのドキュメントは例を見て、
>>> article.publish_date
datetime.datetime(2013, 12, 30 0, 0)
私はこれをやっています私はかなり確信しています。誰かが私の問題を見ていたかどうかはわかりません。