Parsemeta.php

From Wiki2
Revision as of 18:04, 3 December 2008 by Tim (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
#!/usr/bin/php -w
<?
//$fname = $argv[1];//still working to make this run from command line args
$fname = '2ism/v/tfa.txt';
$lines = file($fname)or die("yo can't open file \n");
$outFile = "2ism/v/tfaWikiv.txt";
$fh = fopen($outFile, 'w') or die("can't open file");
// Loop through $lines array, lookup meta description tag for def of each $wrd.
foreach ($lines as $line_num => $wrd) {
	$tags = get_meta_tags('http://www.answers.com/'.$wrd);
	$thedef = $tags['description']."\n";//pick out the description tag and keep the string
	$thewords = explode(" ", $thedef);//explode it 
	$thewords[0]=";".$thewords[0].":";//put the first word in wiki format
	$wikidef = implode(" ",$thewords)."\n";//put the string back together
	fwrite($fh, $wikidef);
	echo $wikidef;
}
fclose($fh);
?>