I want to add a certain category ([[Category:Wiki Green pages]]http://www.appropedia.org/Category:Wiki_Green_pages) to a list of pages. The problem is, the list is old and many of them have been moved since then.
Is there a way I can make the bot detect a redirect, follow it, then add the category on the new page? Or at least some easier way than looking each page up separately and adding the category?
Many thanks!
On Thu, November 20, 2008 8:15 am, Chris Watkins wrote:
Is there a way I can make the bot detect a redirect, follow it, then add the category on the new page? Or at least some easier way than looking each page up separately and adding the category?
wikipedia.py will return a IsRedirectPage exception with the new page title as exception text. If you catch the exception, read the text (try: (..) except IsRedirectPage, e: print e.message) and get that page. For use in category.py you could adapt line 354 and further (except wikipedia.IsRedirectPage, arg:) to read that page name and act upon it.
Hopefully this answers your question.
Best regards,
Merlijn 'valhallasw' van Deen
Thanks! Unfortunately I am not a coder, and have no idea how to implement that, We don't have any coders heavily involved with Appropedia.org (there's always a lot of competition for the attention of socially-minded hackers).
I was going to ask if you could help a bit more with the specifics, but there might be an easier way:
Is there a way I could run the bot, changing the regular pages, and capturing the names of all the redirect page in a file? There might only be 50 or 100 such pages, and I could find another way to handle those (make it into a list of links, open every page, and copy the names of the target pages to a file one by one).
Thanks again, Chris
On Sat, Nov 22, 2008 at 14:57, Merlijn van Deen valhallasw@arctus.nlwrote:
On Thu, November 20, 2008 8:15 am, Chris Watkins wrote:
Is there a way I can make the bot detect a redirect, follow it, then add the category on the new page? Or at least some easier way than looking each page up separately and adding the category?
wikipedia.py will return a IsRedirectPage exception with the new page title as exception text. If you catch the exception, read the text (try: (..) except IsRedirectPage, e: print e.message) and get that page. For use in category.py you could adapt line 354 and further (except wikipedia.IsRedirectPage, arg:) to read that page name and act upon it.
Hopefully this answers your question.
Best regards,
Merlijn 'valhallasw' van Deen
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
On Sat, November 22, 2008 11:23 pm, Chris Watkins wrote:
Is there a way I could run the bot, changing the regular pages, and capturing the names of all the redirect page in a file? There might only be 50 or 100 such pages, and I could find another way to handle those (make it into a list of links, open every page, and copy the names of the target pages to a file one by one).
The easiest way to do add -log:abc.txt to the command. After running, open logs/abc.txt, which contains something like
valhallasw@elladan:~/pywikipedia/trunk/pywikipedia/logs$ cat uit.txt Getting 3 pages from wikipedia:nl...
Gebruiker:Valhallasw/dp <<<
Current categories: Adding [[Categorie:Test]] Changing page [[nl:Gebruiker:Valhallasw/dp]] WARNING: Gebruiker:Valhallasw-bot is redirect to Gebruiker:Valhallasw. Ignoring. Dumping to category.dump.bz2, please wait...
Then search for all lines having 'is redirect to', or use (for example) sed and grep to get a tab-separated list:
valhallasw@elladan:~/pywikipedia/trunk/pywikipedia/logs$ grep uit.txt -e 'is redirect to' | sed -e 's/WARNING: (.*?) is redirect to (.*?). Ignoring./\1\t\2/' Gebruiker:Valhallasw-bot Gebruiker:Valhallasw
Good luck! --valhallasw