Parsephr.php
From Wiki2
#!/usr/bin/php -w <? //$fname = $argv[1];//still working to make this run from command line args $fname = '4bip/v/leasingtherain.txt'; $lines = file($fname)or die("yo can't open file \n"); $outFile = "4bip/v/Vocabltr.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 => $phrase) { echo $phrase; $inbo=preg_match('/<b>.*?<\/b>/',$phrase,$matches); echo $matches[0]."\n"; $sections=split("<[/]?b>", $matches[0]); $wrd = $sections[1]; //$wrd=preg_replace( '/\r\n/', '', trim($wrd) );//get rid of the line return $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]=""; $wikidef = implode(" ",$thewords)."\n";//put the string back together fwrite($fh, $wikidef); echo $wrd . " " . $phrase . " ". $wikidef; } fclose($fh); ?>