Jim Safley | 2 Apr 2010 00:35
Picon
Gravatar

Return parsed wikitext without [edit] links

I'm looking for a way to return parsed wikitext without [edit] links
or any other text that mediawiki returns only while logged in. In
other words, I want action=parse to return parsed wikitext as if a
logged in user was not logged in. Is this possible?

Thanks,
Jim
Roan Kattouw | 2 Apr 2010 00:59
Picon

Re: Return parsed wikitext without [edit] links

2010/4/2 Jim Safley <jimsafley <at> gmail.com>:
> I'm looking for a way to return parsed wikitext without [edit] links
> or any other text that mediawiki returns only while logged in. In
> other words, I want action=parse to return parsed wikitext as if a
> logged in user was not logged in. Is this possible?
>
Is it an option to just log out, then use action=parse? Why go through
the trouble of impersonating a logged-out user when you can just log
out?

I guess this doesn't really work if you're like a JS gadget, though.

Roan Kattouw (Catrope)
Robert Ullmann | 2 Apr 2010 13:55
Picon

Re: Return parsed wikitext without [edit] links

Hi,

The "log in" process involves (as usual for almost all sites) sending
the server a username and password etc, and getting back a cookie or
cookies, which are then sent with each request. Browsers do this
automatically, they don't "know" that there is a login, they just send
back whatever cookies they have been given.

If, as Catrope says, you are in js or something, with no control over
the HTTP request, you can't do much about that except logging out (you
might be able to save and restore the cookies?). But if you are doing
the HTTP request, just leave out the cookies, and you will look
"logged out" to the server.

For example, code to read the API (or index.php) might look like this:
(from Interwicket)

import urllib
from StringIO import StringIO
from gzip import GzipFile

class MyURLopener(urllib.FancyURLopener):
    version="Interwicket/1.0"

# [...]

        try:
            uo = MyURLopener()
            uo.addheader('Cookie', logindata or '')
            uo.addheader('Accept-Encoding', 'gzip')
(Continue reading)

Jim Safley | 3 Apr 2010 18:45
Picon
Gravatar

Re: Return parsed wikitext without [edit] links

Thank you all for your helpful input. If anonymous editing is enabled
(as it is by default) the [edit] links are always present in the
parsed wikitext. Is there a way to remove them if even if no cookies
exist?

Jim
Roan Kattouw | 3 Apr 2010 18:49
Picon

Re: Return parsed wikitext without [edit] links

2010/4/3 Jim Safley <jimsafley <at> gmail.com>:
> Thank you all for your helpful input. If anonymous editing is enabled
> (as it is by default) the [edit] links are always present in the
> parsed wikitext. Is there a way to remove them if even if no cookies
> exist?
>
There's a hack:

http://en.wikipedia.org/w/api.php?action=parse&text=__NOEDITSECTION__{{:Foo}}

Roan Kattouw (Catrope)
Nicolas Vervelle | 4 Apr 2010 17:43
Picon

Getting the pageid of a deleted page ?

Hi,

I'd like to obtain the pageid of a page, even if the page has been deleted.
Requests like this one return the pageid only if the page is still existing.

I have written a tool, WikiCleaner, that can, among other things, help for the Check Wikipedia Project.
When an error is fixed, my tool calls an URL to notify the fix has been done (see the Done button on this page).
In the URL, there's a parameter required for the pageid.
When the page has been deleted since the error was detected, I'd like to automatically notify the fix has been done, but I can't get the pageid from the API.

Nico

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Nicolas Vervelle | 4 Apr 2010 17:48
Picon

Pagedeleted error

Hi,

It seems that there's a bug with some pages that have been deleted and restaured after that, but without any more modification. For example, on the French wiki, I get the error when trying to edit fr:Charbonnage. The page exists, its last version was one 2010-03-11 at 12:37:19, but it was deleted and recreated later this day (at 17:45).

Request made: http://fr.wikipedia.org/w/api.php?summary=[[:fr:Utilisateur:NicoV/Wikipedia Cleaner/Documentation|WikiCleaner]] 0.99 - Correction des [[Projet:Liens vers les pages d'homonymie|liens vers les pages d'homonymie]]&title=Charbonnage&text=[[Image:Drilling of blastholes with air drill.png||thumb|upright 1.5]]...&basetimestamp=2010-03-11T12:37:19Z&token=xxxxxx+\&minor=&bot=&action=edit&format=xml

Error reported: pagedeleted - The page has been deleted since you fetched its timestamp

Nico

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Nicolas Vervelle | 4 Apr 2010 17:49
Picon

Parsing into printable text ?

Hi,

Is there a way to parse a wiki text to get a simplified text (without HTML, external and internal replaced by their text, ...) ?

My need is the following :

  • The project Check Wikipedia uses a configuration file for each wiki (for example: en)
  • It's used among other things to generate pages in Wiki format (for example: en)
  • In the configuration file, you can see for example a description of error n°1: error_001_desc_script=This article has no bold title like <nowiki>'''Title'''</nowiki>, so it contains Wiki text.
  • I am writing a Java program (WikiCleaner) to help fixing the errors reported by this tool. I'd like to display this text in my program as a simple text: This article has no bold title like '''Title'''.
Thanks,
Nico
_______________________________________________
Mediawiki-api mailing list
Mediawiki-api <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Platonides | 4 Apr 2010 23:14
Picon

Re: Pagedeleted error

El 04/04/10 17:48, Nicolas Vervelle wrote:
> Hi,
> 
> It seems that there's a bug with some pages that have been deleted and
> restaured after that, but without any more modification. For example, on
> the French wiki, I get the error when trying to edit fr:Charbonnage
> <http://fr.wikipedia.org/wiki/Charbonnage>. The page exists, its last
> version was one 2010-03-11 at 12:37:19, but it was deleted and recreated
> later this day (at 17:45).
> 
> Request made:
> http://fr.wikipedia.org/w/api.php?summary=[[:fr:Utilisateur:NicoV/Wikipedia
> Cleaner/Documentation|WikiCleaner]] 0.99 - Correction des [[Projet:Liens
> vers les pages d'homonymie|liens vers les pages
> d'homonymie]]&title=Charbonnage&text=[[Image:Drilling of blastholes with
> air drill.png||thumb|upright
> 1.5]]...&basetimestamp=2010-03-11T12:37:19Z&token=xxxxxx+\&minor=&bot=&action=edit&format=xml
> 
> Error reported: pagedeleted - The page has been deleted since you
> fetched its timestamp
> 
> Nico

I think you need to provide starttimestamp to avoid that.
Note that without that check, you would be recreating deleted pages if
saving after the actual deletion.
Platonides | 4 Apr 2010 23:15
Picon

Re: Parsing into printable text ?

El 04/04/10 17:49, Nicolas Vervelle wrote:
> Hi,
> 
> Is there a way to parse a wiki text to get a simplified text (without
> HTML, external and internal replaced by their text, ...) ?
> 
> My need is the following :
> 
>     * The project Check Wikipedia
>       <http://de.wikipedia.org/wiki/Benutzer:Stefan_K%C3%BChn/Check_Wikipedia>
>       uses a configuration file for each wiki (for example: en
>       <http://toolserver.org/%7Esk/checkwiki/enwiki/enwiki_translation.txt>)
>     * It's used among other things to generate pages in Wiki format (for
>       example: en
>       <http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Check_Wikipedia>)
>     * In the configuration file, you can see for example a description
>       of error n°1: /error_001_desc_script=This article has no bold
>       title like <nowiki>'''Title'''</nowiki>/, so it contains Wiki text.
>     * I am writing a Java program (WikiCleaner
>       <http://en.wikipedia.org/wiki/User:NicoV/Wikipedia_Cleaner/Documentation>)
>       to help fixing the errors reported by this tool. I'd like to
>       display this text in my program as a simple text: /This article
>       has no bold title like '''Title'''./
> 
> Thanks,
> Nico

Use a text label.

Gmane