This is a little example how to crawl a web page with PHP, in this example I crawl my own page with XPATH to get all titles.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php # turn erros of libxml_use_internal_errors(true); # creat DomDocument Object $DOM = new DomDocument; # load the THML $DOM->loadHTMLFile("/"); # creat DomXPath Object $XPATH = new DomXPath($DOM); # get all titles with XPATH $mynodes = $XPATH->query("//article//header//h1"); # print result foreach ($mynodes as $i => $mynodes) { echo "[$i] => '", $mynodes->nodeValue, "'n"; } ?> |
This is our result, this are the matches from the XPATH:
1 2 3 4 5 6 7 8 9 10 |
[0] => 'create multiple file in shell with touch' [1] => 'Format current Date in Perl and Bash' [2] => 'Perl Print Benchmark' [3] => 'Perl simple Data Dumper for references' [4] => 'Arduino C Program LED Blink' [5] => 'Perl Constant Benchmark' [6] => 'Benchmark Debug perl' [7] => 'Programmier-Einleitung in C/C++' [8] => 'perl debug output' [9] => 'crontab via script' |
To see this in Perl click: Perl crawl example.
Useful info. Lucky me I found your site by chance, and I am stunned why this coincidence did not came
View Commentabout earlier! I bookmarked it.