【发布时间】:2016-01-13 03:25:10
【问题描述】:
目前我在过滤它时遇到了一堆问题,因此只有包含字符串 http://www.example.com/?dl_name= 的帖子才能通过。
第一个 if 声明完美无缺,但第二个返回我正在抓取的每个帖子,即使是上面没有包含 URL 的帖子我做错了什么?
$url = ''.$element->href;
$html2 = file_get_html($url);
$title = $html2->find('.single-style1-title h1',0);
$s = $title->plaintext;
$str2 = explode ("MUSIC:", $s);
print '<br>';
$date = $html2->find('strong > a',0);
$n = $date->href;
$str = explode ("http://www.example.com/?dl_name=", $n);
if (strpos($title->plaintext,"VIDEO:")===FALSE) {
if (strpos($n,'http://www.example.com/?dl_name=') !== true) {
$image = $html2->find('.thumb-wrap img',0);
//$date = $html2->find('strong > a',0);
//$n = $date->href;
print '<br><br>';
echo $url;
print '<br>';
print htmlspecialchars_decode($image->src);
print '<br>';
print $str2[1];
print '<br>';
print $str[1];
}
}
【问题讨论】:
-
我对 strpos 的使用无法正常工作 - 在那里,为您解决了这个问题 :-)