我可以通过Source
为每个文章URL创建一个来做到这一点。(免责声明:不是python开发人员)
import newspaper
urls = [
'http://www.baltimorenews.net/index.PHP/sid/234363921',
'http://www.baltimorenews.net/index.PHP/sid/234323971',
'http://www.atlantanews.net/index.PHP/sid/234323891',
'http://www.wpbf.com/news/funeral-held-for-gabby-desouza/33874572',
]
class SingleSource(newspaper.source):
def __init__(self, articleURL):
super(StubSource, self).__init__("http://localhost")
self.articles = [newspaper.Article(url=url)]
sources = [SingleSource(articleURL=u) for u in urls]
newspaper.news_pool.set(sources)
newspaper.news_pool.join()
for s in sources:
print s.articles[0].html