<font class="detDesc">Uploaded <b>2015-02-21 19:51:38</b>,
Size (7.37 MB), ULed by
<a class="detDesc" href="/user/FirstUploads/"
title="Browse FirstUploads">FirstUploads</a>
</font>
hello am new to Simple HTML DOM
i want to scrape this dynamic size area -> (7.37 MB) only..
am using this code..
<?php
include 'simple_html_dom.php';
$html = file_get_html('http://some site.com/');
foreach($html->find('font[class=detDesc] b') as $size2)
{
$size[]= $mysqli->real_escape_string(trim($size2->plaintext));
echo $size2->plaintext.'<br>';
}
?>
but its giving me this -> (2015-02-21 19:51:38)..
as i want only -> (7.37 MB)
any suggestions.. ?
You need a combination of CSS and regex:
$desc = $html->find('.detDesc', 0);
if(preg_match('/\d+\.\d{2} [MKG]?B/', $desc->text(), $m)){
echo $m[0];
}