php - How to get <pre> tag contents using preg_match_all? -


i need scrap webspage inside <pre> tag contents. using preg_match_all function not working.

my scraping website <pre> tag content given below.

<pre># mon jul 22 03:10:03 cdt 2013  99.46.177.18 99.27.119.169 99.254.168.132 99.245.96.210 99.245.29.38 99.240.245.97 99.239.100.211 <pre> 

php file

updated

$data = file_get_contents('http://www.infiltrated.net/blacklisted'); preg_match_all ("/<pre>([^`]*?)<\/pre>/", $data, $matches); print_r($matches); exit; 

my php file returns empty array. know preg_match_all function problem.

how can pre tag contents. please guide me.

edit question

i can run @pieter script. returns array()

my script given below.

    <?php     $url = 'http://www.infiltrated.net/blacklisted';     $data = new domdocument();     $data->loadhtml(file_get_contents($url));     $xpath = new domxpath($data);      $pre_tags = array();     foreach($xpath->query('//pre') $node){     $pre_tags[] = $node->nodevalue;      }  print_r($pre_tags); exit; ?> 

use php functions loop through dom. using regex-patterns html tags discouraged.

try code:

$data = new domdocument(); $data->loadhtml(file_get_contents($url)); $xpath = new domxpath($data);  $pre_tags = array(); foreach($xpath->query('//pre') $node){     $pre_tags[] = $node->nodevalue; } 

or try php simple html dom parser, see: http://simplehtmldom.sourceforge.net/


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -