首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python:报纸模块-从多个URL下载

Python:报纸模块-从多个URL下载
EN

Stack Overflow用户
提问于 2017-04-03 01:39:01
回答 1查看 377关注 0票数 1

我不想开始一个新的帖子,但我正试图完成这个问题中描述的确切的事情:Python: Newspaper Module - Any way to pool getting articles straight from URLs?

但是,在尝试实现解决方案时,我会得到以下错误:

代码语言:javascript
复制
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

会非常感激你朝正确的方向前进。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-03 04:16:05

由于未定义StubSource,因此链接答案中的错误看起来像错误。

代码语言:javascript
复制
class SingleSource(newspaper.Source):
    def __init__(self, articleURL):
        super(StubSource, self).__init__("http://localhost")
        self.articles = [newspaper.Article(url=url)]

可能应该是:

代码语言:javascript
复制
class SingleSource(newspaper.Source):
    def __init__(self, articleURL):
        super(SingleSource, self).__init__("http://localhost")
        self.articles = [newspaper.Article(url=url)]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43175383

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档