2012-06-18 5 views
1

에게 FIRST (foo는, 0) 간단한 HTML DOM를 사용하여 활동 목록의 요소를 반환이 코드구문 분석 HTML 내용과 사업부 속성

$html = file_get_html('http://runkeeper.com/user/'.RUNKEEPER_ID.'/activity/'); 
$link1 = $html->find('.activityMonth', 0); 

을 반환합니다. 내가 처음 사업부의 "링크"속성을 구문 분석하고 (이 경우 95648619) 활동 ID를 검색해야

<div class="activityMonth menuItem selected" link="/user/zzvimercm/activity/95648619"><div class="highlight"></div><div class="distanceUnit">km.</div><div class="distance">7.26</div> 
<div class="day"><img src="http://d2b4ufapzmnxpw.cloudfront.net/build/3694/static/kronos/images/icon-calendar-17.png" width="24" height="26" border="0" /></div> 
<div class="mainText">Running</div> 
</div> 

:

다음은 출력 ($ 링크 1의 내용)입니다. 나는 sscanf 또는 Simple HTML DOM 자체가 트릭을 할 수 있다고 생각하지만 지금까지는 성공하지 못했습니다.

힌트가 있습니까? 사전에

감사

답변

0

예 :

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

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

큰 감사를 많이 작동합니다. – flapane