Hi Pywikipedians,
Is there a method for getting the inbound redirects that point to a page?
For example, given the urlname=Death_of_Michael_Jackson, how do I get the pages that redirect to it?
Thanks for advice!
jrf
http://en.wikipedia.org/w/api.php?action=query&list=backlinks&bltitl...
Regards
Date: Mon, 13 Feb 2012 10:28:28 -0500 From: jrf@mit.edu To: pywikipedia-l@lists.wikimedia.org Subject: [Pywikipedia-l] getRedirects?
Hi Pywikipedians,
Is there a method for getting the inbound redirects that point to a page?
For example, given the urlname=Death_of_Michael_Jackson, how do I get the pages that redirect to it?
Thanks for advice!
jrf
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
On 13 February 2012 16:28, John R. Frank jrf@mit.edu wrote:
Is there a method for getting the inbound redirects that point to a page?
For example, given the urlname=Death_of_Michael_**Jackson, how do I get the pages that redirect to it?
print wikipedia.Page.getReferences.__doc__
Yield all pages that link to the page by API
If you need a full list of referring pages, use this: pages = [page for page in s.getReferences()] Parameters: * follow_redirects - if True, also returns pages that link to a redirect pointing to the page. * withTemplateInclusion - if True, also returns pages where self is used as a template. * onlyTemplateInclusion - if True, only returns pages where self is used as a template. * redirectsOnly - if True, only returns redirects to self.
references = wikipedia.Page('en',
'Death_of_Michael_Jackson').getReferences(redirectsOnly=True)
references.next()
Getting references to [[en:Death of Michael Jackson]] via API... Page{[[en:Reaction to the death of Michael Jackson]]}
references.next()
Page{[[en:Tohme Tohme]]}
references.next()
Page{[[en:Michael Jackson's death]]}
references.next()
Page{[[en:Death of michael jackson]]}
references.next()
Page{[[en:R.i.p michael jackson]]}
references.next()
Page{[[en:Ed Chernoff]]}
references.next()
Page{[[en:Life and death of Michael Jackson]]}
references.next()
Page{[[en:Michael Jackson Family Trust]]}
Best, Merlijn
Thanks --- both of these responses are super helpful!
I had been confused about getReferences. Now I get it.
jrf
On Mon, 13 Feb 2012, Merlijn van Deen wrote:
On 13 February 2012 16:28, John R. Frank jrf@mit.edu wrote: Is there a method for getting the inbound redirects that point to a page?
For example, given the urlname=Death_of_Michael_Jackson, how do I get the pages that redirect to it?
print wikipedia.Page.getReferences.__doc__
Yield all pages that link to the page by API
If you need a full list of referring pages, use this: pages = [page for page in s.getReferences()] Parameters: * follow_redirects - if True, also returns pages that link to a redirect pointing to the page. * withTemplateInclusion - if True, also returns pages where self is used as a template. * onlyTemplateInclusion - if True, only returns pages where self is used as a template. * redirectsOnly - if True, only returns redirects to self.
references = wikipedia.Page('en', 'Death_of_Michael_Jackson').getReferences(redirectsOnly=True) references.next()
Getting references to [[en:Death of Michael Jackson]] via API... Page{[[en:Reaction to the death of Michael Jackson]]}
references.next()
Page{[[en:Tohme Tohme]]}
references.next()
Page{[[en:Michael Jackson's death]]}
references.next()
Page{[[en:Death of michael jackson]]}
references.next()
Page{[[en:R.i.p michael jackson]]}
references.next()
Page{[[en:Ed Chernoff]]}
references.next()
Page{[[en:Life and death of Michael Jackson]]}
references.next()
Page{[[en:Michael Jackson Family Trust]]}
Best, Merlijn
pywikipedia-l@lists.wikimedia.org