loadHTML($html); $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); return element_to_obj($dom->documentElement); } function element_to_obj($element) { $obj = array( "tag" => $element->tagName ); foreach ($element->attributes as $attribute) { $obj[$attribute->name] = $attribute->value; } foreach ($element->childNodes as $subElement) { if ($subElement->nodeType == XML_TEXT_NODE) { $obj["html"] = $subElement->wholeText; } else { $obj["children"][] = element_to_obj($subElement); } } return $obj; } //Собираем артикульные страницы самсона require_once 'mysql7.php'; //$db = new MySQL('/home/yuec/www/scripts/tk.db', 'SQLITE3', '', '', ''); $db = new MySQL('tk-ligat', 'MYSQL', 'localhost', 'admin', '32143214'); $sql ="SELECT * FROM `donorLinks` WHERE `art`=" . $argv[1] . " LIMIT 1"; //echo $sql; $db->debug=0; $all_tovar=$db->free_sql($sql); $count = count( $all_tovar ); for ($i=0; $i<$count; $i++){ $html = gzuncompress ( base64_decode ( $all_tovar[$i]['html'] ) ); $html = iconv('windows-1251//IGNORE', 'utf-8//IGNORE', $html); $rest = substr($all_tovar[$i]['link'], -6); $a = html_to_obj($html); $foolname = strip_tags ( $a['children'][1]['children'][1]['children'][1]['children'][0]['children'][0]['children'][3]['children'][0]['children'][0]['children'][0]['children'][0]['children'][0]['children'][0]['alt'] ); DB::set("UPDATE `tovar` SET `title`=? WHERE `artikul`=?", array( $foolname, $argv[1] ) ); } ?>