[英]Python: Newspaper Module - Downloading from multiple URLs
我討厭開始一個新的帖子,但我正在努力完成這個問題中描述的確切事情: Python:報紙模塊 - 任何方式來直接從URL獲取文章?
但是,在嘗試實現解決方案時,我收到以下錯誤:
NameError Traceback (most recent call last)
<ipython-input-38-2707f1416873> in <module>()
----> 1 sources = [SingleSource(articleURL=u) for u in urls]
2
3 newspaper.news_pool.set(sources)
4 newspaper.news_pool.join()
5
<ipython-input-38-2707f1416873> in <listcomp>(.0)
----> 1 sources = [SingleSource(articleURL=u) for u in urls]
2
3 newspaper.news_pool.set(sources)
4 newspaper.news_pool.join()
5
<ipython-input-37-4949a9e51da5> in __init__(self, articleURL)
1 class SingleSource(newspaper.Source):
2 def __init__(self, articleURL):
----> 3 super(StubSource, self).__init__("http://localhost")
4 self.articles = [newspaper.Article(url=url)]
NameError: name 'StubSource' is not defined
非常感謝推動正確的方向。
由於StubSource
,因此鏈接答案中的拼寫錯誤
class SingleSource(newspaper.Source):
def __init__(self, articleURL):
super(StubSource, self).__init__("http://localhost")
self.articles = [newspaper.Article(url=url)]
應該是:
class SingleSource(newspaper.Source):
def __init__(self, articleURL):
super(SingleSource, self).__init__("http://localhost")
self.articles = [newspaper.Article(url=url)]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.