- OVERVIEW
- USAGE
- RESOURCE
OVERVIEW ¶
- A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way!
- Supports invalid HTML.
- Find tags on an HTML page with selectors just like jQuery.
- Extract contents from HTML in a single line.
USAGE ¶
Yii::import('ext.SimpleHTMLDOM.SimpleHTMLDOM');
$simpleHTML = new SimpleHTMLDOM;
$html = $simpleHTML->file_get_html('http://www.google.com/');
foreach($html->find('img') as $element)
echo $element->src . '<br>';
foreach($html->find('a') as $element)
echo $element->href . '<br>';
RESOURCE ¶
http://simplehtmldom.sourceforge.net/
Great thank simple worked
Thanx simply worked.
My Code Load MLB game schedule from espn, I worked hard but finally i got it, it returns array of game day, games vs concatinated with game time in array
public static function Load_MLB($name){ Yii::import("application.vendors.*"); include 'simple_html_dom.php'; $html = file_get_html('http://espn.go.com/'.$name.'/schedule'); $item = array(); $games = array(); $i =1; foreach($html->find('table.tablehead tbody') as $data) { $item['gameday'][$i] = $data->find('tr.stathead td',0)->innertext; foreach($data->find('tr td') as $tdata): $games[$i][]= $tdata->innertext; endforeach; $i++; } $item = array_filter($item['gameday']); $j=1; $newkey = array(); foreach($games as $game): if($game[1]=='RESULT'){ } else { //$newkey = array(); $newkey[$j]['gameday'] = $game[0]; $game = array_filter($game); for($i=6;$i<sizeof($game);$i=$i+5): $newkey[$j][] = $game[$i].'--'.$game[$i+1]; endfor; } $j++; endforeach; return $newkey; }
More recent variant of this extension...
https://github.com/tpruvot/simple_html_dom
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.