[wd_asp elements=’search’ ratio=’100%’ id=1]

Webscraping words from a website

28th October 2013

Php - Miscellaneous

php codehaven

loadHTML($html);
libxml_clear_errors(); //remove errors for yucky html

$pokemon_xpath = new DOMXPath($pokemon_doc);

//get all the h2's with an id
// $pokemon_row = $pokemon_xpath->query('//a'); Use this for all links
//$pokemon_row = $pokemon_xpath->query('//div[@class="prog col"]'); //class="whatever"
$pokemon_row = $pokemon_xpath->query('//a[@class="title "]'); // links with class of title , note the extra space.

if($pokemon_row->length > 0){
foreach($pokemon_row as $row){
echo $row->nodeValue . "
";
}
}
}
?>