Wikinews:Water cooler/technical/archives/2021/January


How to use mediawiki python API to get list of articles (in completion) under 'Latest Stories' section under any category with the dates listed?

If you say have this screen (https://i.postimg.cc/cHV97sCV/wikicat.png)

I want all the articles with date, sorted by the date under 'Latest Stories' section of any Category page (eg. Science and Technology). I'm using wikimedia python API. Can someone please give me a solution which uses the same?

thanks, —The preceding unsigned comment was added by Gdass (talkcontribs) 19:35, 27 October 2020 (UTC)[reply]


In case anyone comes across this looking for a solution: there are other ways to get dates like the date being present in the category or the first line of the content (article-text). But no direct way to get dates from the category page itself (to avoid reading the article, I've noticed that sometimes these dates are different than dates in the actual article). If someone can figure that out, then please add the solution here.—The preceding unsigned comment was added by Gdass (talkcontribs)

@Gdass: This one is rather tricky. You need to run a SQL query for this. Please see this. I don't think it is the most efficient, but it works. As far as MW APIs are concerned, unfortunately there are no direct APIs to find intersection. Explanation: Lastest stories in Category:Foo must also be in Category:Published. And it's pubilshed date is the timestamp when it was added in Category:Published (UTC time). Hope this helps.
•–• 09:45, 28 October 2020 (UTC)[reply]
What you need to find is how to connect to this server, and how to get a JSON request. Is this what you had been looking for?
•–• 13:13, 28 October 2020 (UTC)[reply]
perhaps Special:newsfeed would be useful (it takes url parameters). Bawolff 21:15, 1 January 2021 (UTC)[reply]