【问题标题】:Accesing DOM elements with PHP Simple DOM使用 PHP Simple DOM 访问 DOM 元素
【发布时间】:2016-09-05 20:50:15
【问题描述】:

我想从 YMCA 本地计划中提取数据,数据表位于 div="scheduler_here" 下。对于这个项目,我使用PHP Simple HTML DOM Parser。但它没有显示任何数据。

<?php
// Include the library
include('simple_html_dom.php');

// Retrieve the DOM from a given URL
$html = file_get_html('http://www.activelifeadmin.com/newyork/websearch/public/index/weekview?sched=Group%20Exercise%20Schedule,Large%20Pool,Small%20Pool&branch_ids=38#/');

// Find the DIV tag with an id of "myId"
foreach($html->find('div[scheduler_here]') as $e)
    echo $e->innertext . '<br>';
?>

Output PHP

YMCA Website

【问题讨论】:

    标签: php dom html-parsing


    【解决方案1】:

    需要通过id属性获取:

    foreach($html->find('div[id=scheduler_here]') as $e)
    

    【讨论】:

      猜你喜欢
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 2014-03-18
      • 2021-09-05
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多