Skip to content

Instantly share code, notes, and snippets.

@ilyabrin
Created May 30, 2011 08:39
Show Gist options
  • Save ilyabrin/998614 to your computer and use it in GitHub Desktop.
Save ilyabrin/998614 to your computer and use it in GitHub Desktop.
PHP parser
<?php
for ($i=1; $i <= 17441; $i++) {
$html = file_get_contents('http://www.vsmolenske.ru/firma.php?id='.$i);
echo $html;
break;
$Matched = array();
/** создаем новый dom-объект **/
$dom = new domDocument;
/** загружаем html в объект **/
$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
/** элемент по тэгу **/
$div_elements = $dom->getElementsByTagName('div');
for($i=0;$i<$div_elements->length;$i++) {
/** получаем все вложенные элементы div **/
/** $div_content = $div->item(0)->getElementsByTagName('tr'); **/
if($div_elements->item($i)->attributes->getNamedItem('class')->nodeValue == 'fll inf_firm') {
$Matched[]=$div_elements->item($i);
}
}
return $Matched;
}
echo $Matched;
/* for end */
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment