Jim Higson wrote:
Brion Vibber wrote:
Jim Higson wrote:
How can I check if a page exists from a program?
You can hit Special:Export/Pagename; if the response contains no <page>
elements, the page does not exist.
Do you know any way that does not involve getting the whole article text?
I've looked at sending HEAD requests to Specail:Export and turned up some
unexpected behaviour. Like action=raw, it always returns 200, but for
articles with a space in the name you can tell if it is new because
Content-Length is always 100.
For articles without a space in the name Specail:Export export never sends
Content-Length to HEADs :)
Of course, this isn't reliable at all. Is there any chance action=raw
could be made to return 404, or Content-Length: 0 for non-existing
articles?
Little update (very hackish!)
You can force the wikimedia server to return the Content-Length field by
inserting a space into the URL, for example:
http://localhost/wiki/index.php/Special:Export/%20dancing
200
Date: Sun, 27 Feb 2005 01:15:40 GMT
Server: Apache/2.0.51 (Fedora)
X-Powered-By: PHP/4.3.10
Content-Encoding: gzip
Vary: Accept-Encoding
Content-Length: 347
Connection: close
Content-Type: application/xml; charset=utf-8
This at least gives a consistant (at least until this oddness is fixed) way
to tell if a page exits, so I know to colour my links red or blue.
Jim