newspaper4k icon indicating copy to clipboard operation
newspaper4k copied to clipboard

Getting older articles

Open AndyTheFactory opened this issue 2 years ago • 9 comments

Issue by tehnar Tue May 10 17:51:26 2016 Originally opened as https://github.com/codelucas/newspaper/issues/245


Hello, is there any way to get more articles from a particular website? I get only the latest (amount and beginning date depends on site) news, not all of them. Caching is disabled, but it doesn't help.

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by yprez Tue May 10 18:31:50 2016


@tehnar can you provide a specific example?

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by tehnar Tue May 10 18:38:40 2016


@yprez For example, http://blog.jetbrains.com/ruby/ Newspaper thinks that there are only 94 articles while the real amount is much larger. The latest article downloaded by newspaper is dated autumn 2015.

Also, there is an additional trouble with this website: if I try some other blog (for example, http://blog.jetbrains.com/pycharm/), I'll get 0 articles. I've managed to fix it by manually deleting contents of ~/.newspaper/feed_category_cache, but it's a strange hack.

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by yprez Wed May 11 10:28:39 2016


Did you try disabling cache? e.g. newspaper.build('http://blog.jetbrains.com/ruby/', memoize_articles=False)

I'm getting 127 articles from http://blog.jetbrains.com/ruby/, not sure if it's all of them or not. I think you're getting 0 on the 2nd result because the articles are cached by the domain...

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by tehnar Wed May 11 10:37:52 2016


@yprez I'm still getting only 95 articles (I disabled caching and removed ~/.newspaper_scraper). There are 32 pages (the last page http://blog.jetbrains.com/ruby/page/32/), 10 articles on each, 320 articles in total, the first article is published in 2010, while I'm getting only articles published in 2015-2016

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by tehnar Fri May 13 13:37:09 2016


Also, publish dates are not extracted properly for all the articles. For example, publish date for this article http://blog.jetbrains.com/ruby/2016/05/rubymine-2016-1-1-security-update/ is not recognized while for this article http://blog.jetbrains.com/ruby/2015/12/20-years-of-ruby/ it's extracted properly. It looks like a bug.

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by yprez Fri May 13 19:33:49 2016


Funny, but the bug with parsing the date is actually in the 2nd article where it succeeds...

It parses the date from the URL (I couldn't find any meta date attributes in these articles), so 2015/12/20 part is parsed as a date, and the result is wrong too (20/05/2015 instead of the 22nd)

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by tehnar Fri May 13 19:54:16 2016


@yprez Oh, really funny bug :) How about adding some more regexps for different date formats? I suppose that not so many sites represent date as year/month/day. Actually, I think that most of websites put the year as the last part of publish date (but I might be wrong). And what about a low amount of downloaded articles? Is that a king of bug, or what?

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by yprez Sat May 14 13:21:43 2016


There was a ticket about trying to find dates with regex within the article - #168, and a closed pull-request somewhere. Can't really get it from the URL if it only has the year and month.

Regarding the amount of articles, newspaper combines several strategies to get a list of articles, e.g. links from the page, categories, rss feeds, etc. It doesn't go over the pages of paginated results... The first page http://blog.jetbrains.com/ruby/ only has articles from January 2016, same about the rss feed at: http://blog.jetbrains.com/ruby/feed/

To get all the articles you would need to paginate over all result pages, I don't think that's currently possible with newspaper...

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory

Comment by tehnar Sat May 14 18:39:49 2016


Ok, I've got it. Thank for the clarification.

AndyTheFactory avatar Oct 24 '23 07:10 AndyTheFactory