headbanger headbanger -4 years ago 150
JSON Question

Trying to search WikiNews

I'm trying to search WikiNews, both for specific news stories and for the latest headlines. I've been reading about the MediaWiki API (https://www.mediawiki.org/wiki/API:Main_page), but it doesn't seem to map to what I'm trying to do.

Taking two examples, I need to be able to get the latest headlines (ideally for a specific region (United States, France, Great Britain etc) and for a specific topic (Finance, Sport, Media etc), but right now I'd settle for just getting the latest stories regardless. I've tried a couple of things:

  1. https://en.wikinews.org/w/api.php?action=query&prop=categories&clprop=timestamp&format=json

    just returns

  2. http://en.wikinews.org/w/api.php?action=query&list=recentchanges&rnnamespace=0
    looks like it might be more promising, but only if I could filter only to show news stories - and show a good deal more than it currently does. Clearly it would also be desirable to add parameters for location / story type in the query rather than filtering them after the list is received.

With regard to searching, I've had even less luck. I've tried searching on a topic that I know is ~~causing trouble~~ making the news:

  1. https://en.wikinews.org/w/api.php?action=query&titles=Donald_Trump&prop=revisions&rvprop=content&format=json&redirects&continue
    the return is not a list of stories!

Has anyone searched WikiNews? Does anyone have any suggestions to achieve what I need to do?

Answer Source

action=query&format=json&list=search&redirects=1&srsearch="Donald Trump" -incategory:disputed incategory:"August_25, _2016|August_24,_2016|August_23,_2016|August_22,_2016|August_21,_2016|August_20,_2016|August_19,_2016|August_18,_2016"&srnamespace=0&srenablerewrites=1 will search for articles from the last few days mentioning Trump. (See full docs on what keywords can be used in a search query.)

Most of your examples do not actually generate a list (you can see from the lack of a list parameter); they expect one or more article name via the titles parameter and return information about those. Your second example is valid (except the correct parameter name is rcnamespace) but that returns recently edited articles, which is a very random way of trying to find news on a topic.

In general it seems like you are trying to randomly guess what the API modules do. Did you miss the docs and sandbox?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download