【问题标题】:Fetch Content from Div Class using PHP Simple HTML DOM Parser使用 PHP Simple HTML DOM Parser 从 Div 类中获取内容
【发布时间】:2018-05-11 02:21:09
【问题描述】:
div class="stars" span title="Money Locker :  Pulsa Gratis average
 rating 3.9" style="width:78%" span div


    $item['stars'] = $article->find('div.stars span', 0)->style;
                $item['stars'] = str_replace("width:", "", $item['stars']);

我只希望它跨越标题 = 数据

我想要这个数据“Money Locker : Pulsa Gratis 平均评分 3.9”

【问题讨论】:

    标签: php html parsing dom


    【解决方案1】:

    尝试两件事:

    使用“title”属性...需要像“style”一样作为span标签的属性存在

    $title = $article->find('div.stars span', 0)->title;
    

    或者你可以使用正则表达式,并在引号之间取标题内容

    preg_match("/span title=\"(.+?)\"/", )
    

    【讨论】:

      猜你喜欢
      • 2011-01-17
      • 1970-01-01
      • 1970-01-01
      • 2012-08-12
      • 2012-04-08
      • 1970-01-01
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      相关资源
      最近更新 更多