<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>
你好,我是Simple HTML DOM的新手
我想刮掉这个动态尺寸区域 - &gt; (7.37 MB)仅.. ..
我正在使用此代码..
<?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>';
}
?>
但它给了我这个 - &gt; (2015-02-21 19:51:38)..
因为我只想要 - &gt; (7.37 MB)
任何建议..?
答案 0 :(得分:0)
您需要CSS和正则表达式的组合:
$desc = $html->find('.detDesc', 0);
if(preg_match('/\d+\.\d{2} [MKG]?B/', $desc->text(), $m)){
echo $m[0];
}