Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

check if wikipedia article exists - PHP

Name: Fagot 2010-02-11 20:08

how can I check if a wikipedia article exists using PHP?
thank you

Name: Anonymous 2010-02-11 23:30

<?php
    $articleName = "Whatever_article_name";
    $maximum_length_of_error_pages = 250; // Current length: 225. Adding buffer in case it changes.
                                          // Like when WP asks for donations.
    $Lenghtest = exec("curl http://en.wikipedia.org/wiki/" . $articleName . " | wc -l | sed 's/^[ \t]*//'");
    if($Lenghtest < $maximum_length_of_error_pages){
        print"This page doesn't exist!";
    } else {
        print"This page exists!";
    }
?>


Enjoy!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List