This works: ("Pirin" is just a random page with some broken links)

https://en.wikipedia.org/w/api.php?action=query&format=json&titles=Pirin&generator=links&formatversion=2&gpllimit=500

https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&titles=Pirin&generator=links&formatversion=2&gpllimit=500

This gives you a list of all links on a page; you need to parse the JSON data and count how many entries have `"missing": true`.

Note that if there are more than 500 links on a page, you'll need to continue the query to get the full list (https://www.mediawiki.org/wiki/API:Query#Continuing_queries). It seems that conveniently all the broken links are listed first, but I'm not sure if this can be relied on.

--
Bartosz Dziewoński

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Reply via email to