【问题标题】:Why the python module newspaper3k only return 0 articles for tencent, sina and wallstreetcn?为什么python模块newspaper3k只返回腾讯、新浪和wallstreetcn的0篇文章?
【发布时间】:2019-04-29 08:34:22
【问题描述】:

paper3k 图书馆非常棒。我对它上瘾了。

请问,为什么 Source 和 build() 只返回大部分中国财经新闻页面的 0 篇文章?

我的代码有什么问题吗?

from newspaper import Article, Source

url='https://wallstreetcn.com/live/global'

result=newspaper.Source(url,language='zh')

result.build()

result.size()

0

【问题讨论】:

    标签: python web-scraping web-crawler python-newspaper sinaweibo


    【解决方案1】:

    我运行您的代码并收到不同的结果,也许您遇到了缓存问题。尝试添加memoize_articles=False,见:

    import newspaper
    
    url='https://wallstreetcn.com/live/global'
    result = newspaper.Source(url, language='zh', memoize_articles=False)
    
    result.build()
    result.size()
    >>> 2
    

    你可以找到文档here

    【讨论】:

      猜你喜欢
      • 2023-02-24
      • 1970-01-01
      • 1970-01-01
      • 2013-07-27
      • 1970-01-01
      • 1970-01-01
      • 2013-12-06
      • 1970-01-01
      • 2012-05-15
      相关资源
      最近更新 更多