2014-02-27 56 views
1

我使用Python Newspaper lib開發了網頁抓取腳本。我需要提取以下內容 - 網址,標題,摘要,作者和出版日期。除了發佈日期之外,我收到了所有的內容我的問題是,有沒有人使用報紙庫來捕獲出版日期?用於在Python中進行網頁抓取的報紙0.0.6

hn.write("***********Article no" + str(x+1) + "************\r\n"); 
hn.write("URL: "+ article.url+ "\r\n"); 
hn.write("Title: "+ article.title + "\r\n"); 
hn.write("Authors: "+' '.join(map(str, article.authors))); 
hn.write("\r\n"); 
hn.write("Summary: "+ article.summary+ "\r\n); 
hn.write("Key words: "); 
hn.write(str(article.keywords).strip('[]')); 

有沒有辦法使用報紙庫獲取發佈日期?

感謝

穆克什

回答

3

有一個在newspaper/article.py

# TODO self.publish_date = self.config.publishDateExtractor.extract(self.doc) 

線195現在看來,這是還沒有準備好。但是你可以試着取消註釋這段代碼。

來源:https://github.com/codelucas/newspaper/blob/master/newspaper/article.py#L195

+1

Furas,謝謝...我註釋掉行和執行腳本。它給我解析錯誤!我想我必須等待這個功能才能實現。 – user3358819

+1

請[報紙作者](https://github.com/codelucas)尋求幫助。 – furas