Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解析HTML内容并返回div属性_Html_Parsing_Dom - Fatal编程技术网

解析HTML内容并返回div属性

解析HTML内容并返回div属性,html,parsing,dom,Html,Parsing,Dom,此代码 $html = file_get_html('http://runkeeper.com/user/'.RUNKEEPER_ID.'/activity/'); $link1 = $html->find('.activityMonth', 0); 将返回使用简单HTMLDOM的活动列表的第一个(foo,0)元素 以下是输出($link1的内容): km.7.26 跑步 我需要解析第一个div的“link”属性,并检索活动id(本例中为95648619)。我想sscanf或简单的h

此代码

$html = file_get_html('http://runkeeper.com/user/'.RUNKEEPER_ID.'/activity/');
$link1  = $html->find('.activityMonth', 0);
将返回使用简单HTMLDOM的活动列表的第一个(foo,0)元素

以下是输出($link1的内容):

km.7.26
跑步
我需要解析第一个div的“link”属性,并检索活动id(本例中为95648619)。我想sscanf或简单的htmldom本身可能会起作用,但到目前为止我还没有成功

有什么提示吗

提前感谢

示例:

// Get the "link"
$link = $html->find('div[link]', 0)->link;

// Explode the link, and get the last item
$activity_id = end(explode('/', $link));
// Get the "link"
$link = $html->find('div[link]', 0)->link;

// Explode the link, and get the last item
$activity_id = end(explode('/', $link));