Hello, everyone.
I have a question: how can I use API to get the number of internal broken links of a page?
Cheers, Shiyue
This works: ("Pirin" is just a random page with some broken links)
https://en.wikipedia.org/w/api.php?action=query&format=json&titles=P...
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=jso...
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.
I see, thanks a lot!!
2016-09-11 22:36 GMT+08:00 Bartosz Dziewoński matma.rex@gmail.com:
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=quer y&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/wik i/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
mediawiki-api@lists.wikimedia.org