Added check if article was found

This commit is contained in:
Jack-Benny Persson 2014-07-28 11:45:09 +02:00
parent d7e9ab5822
commit fbab351305

View File

@ -9,6 +9,13 @@ if (!isset($argv[1]))
$url = $argv[1];
$data = shell_exec("curl -s $url");
preg_match("/\<p\>(.*)\<\/p\>/", $data, $match);
if (!isset($match[1]))
{
print "No Wikipedia article found at that URL\n";
exit(1);
}
$string = strip_tags($match[1]);
print (wordwrap($string, 60, "\n") . "\n");