On Sun, May 29, 2016 at 3:12 PM, Brad Jorsch (Anomie) <[email protected] > wrote:
> On Sat, May 28, 2016 at 8:42 AM, Nicolas Vervelle <[email protected]> > wrote: > >> I find that the result of list=backlinks for page XXX is odd when one of >> the backlinks is a redirect on a different page than XXX, but has also >> contents with a link to XXX. >> >> See for example backlinks to en:Spin-off >> >> https://en.wikipedia.org/w/api.php?bltitle=Spin-off&continue=&action=query&blredirect=&list=backlinks&format=xml&bllimit=max >> >> Among the backlinks, there's for example "User talk:SummerPhD" and all >> pages linking to this talk page : >> >> - It's content contains a link to Spin-off page, so it's normal to >> see it. >> - It's also a redirect (bad practice to have a redirect page with >> contents), so all backlinks to this talk page are also listed while they >> have no relation at all to "Spin-off" >> >> Is it normal to have this behaviour ? >> > This is the documented behavior: the description of the blredirect > parameter[1] says "If linking page is a redirect, find all pages that link > to that redirect as well." [[Spin-off]] is indeed linked from [[User > talk:SummerPhD]], and [[User talk:SummerPhD]] is indeed a redirect. > > If you're looking for actual redirects to [[Spin-off]] rather than all > redirect pages that link to [[Spin-off]], you want to use prop=redirects[2] > instead. You might also consider using prop=linkshere[3] instead of > list=backlinks, as the former allows you to specify multiple titles at the > cost of not having a "blredirect"-style subquery. > > [1]: https://en.wikipedia.org/w/api.php?modules=query+backlinks > [2]: https://en.wikipedia.org/w/api.php?modules=query+redirects > [3]: https://en.wikipedia.org/w/api.php?modules=query+linkshere > Thanks for the answer Brad, If I want to retrieve all pages that link to a given page (either directly or through a redirect), what request(s) should I perform ? If I understand correctly: - with backlinks I have the problem I mentionning in my first email - with redirects I only get the list of redirects so I also have to retrieve the list of links to the initial page and to all the redirects (linkshere probably) - with linkshere I only get the list of pages with a direct link, and I can't tell for redirects if they are to the given page or to an other So, my guess is "redirects" then "linkshere" for Spin-off and all redirects given by the first request? Nico > > -- > Brad Jorsch (Anomie) > Senior Software Engineer > Wikimedia Foundation > > _______________________________________________ > Mediawiki-api mailing list > [email protected] > https://lists.wikimedia.org/mailman/listinfo/mediawiki-api > >
_______________________________________________ Mediawiki-api mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
