function parsePerson($url) { correctConfigForParser(); preg_match("/^(http:\\/\\/)?([^\\/]+)/i", $url, $matches); $host = $matches[2]; preg_match("/[^\\.\\/]+\\.[^\\.\\/]+\$/", $host, $matches); $where = $matches[0]; $res = array(); switch ($where) { case "imdb.com": case "world-art.ru": case "kinopoisk.ru": case "ozon.ru": list($module) = explode(".", $where); require_once dirname(__FILE__) . "/common/webparser/webparser.php"; global $config; $web_parser = new WebParser($config['websites'], $config['customer']); $results = $web_parser->Parse($module, 'person', array('path' => $url)); //echo "<pre>" . print_r($results,true) . "</pre>"; $rusname = ''; $engname = ''; foreach ($results['names'] as $name) { if (!$rusname && lms_rus_eng_detect($name) == 'rus') { $rusname = $name; } if (!$engname && lms_rus_eng_detect($name) != 'rus') { $engname = adapt1252To1251(html2ASCII($name)); } } $res["RusName"] = $rusname; $res["OriginalName"] = $engname; $adaptDate = array('January' => 'января', 'February' => 'февраля', 'March' => 'марта', 'April' => 'апреля', 'May' => 'мая', 'June' => 'июня', 'July' => 'июля', 'August' => 'августа', 'September' => 'сентября', 'October' => 'октября', 'November' => 'ноября', 'December' => 'декабря'); $res["Born"] = $results['born_date']; if (isset($results['born_place'])) { $res["Born"] .= " ({$results['born_place']}) "; } $res["Profile"] = strtolower($results['profile']); $res["About"] = $results['about']; if (isset($config['allowable_tags'])) { $res["About"] = strip_tags($res["About"], $config['allowable_tags']); } $res["Photos"] = $results['photos']; return $res; break; } }
/** * Metoda pobiera dane o produkcie i zapisuje je do bazy danych */ public function getProductData() { $html = parent::loadPage($this->url); $this->setProductName($html); $this->data["products"] = array(); $this->data["products"]["description"] = $html->find(".full-description", 0)->innertext(); $this->data["products"]["name"] = $this->getProductName(); $this->data["products"]["product_specs"] = addslashes($this->getProductSpecs($html)); $this->data["products"]["product_urls"] = $this->url; $this->saveData($this->data); }
/** * Metoda wyszukuje produkt na stronie */ public function findProduct() { $element = parent::loadPage($this->url); $products = $element->find("#promo-list ul"); if (is_array($products) && count($products) > 0) { $options = array(); foreach ($products as $product) { $name = $product->find("li.name a", 0)->text(); $ocena = $product->find("div.note a", 0); if (is_object($ocena)) { $ocena = $ocena->text(); } else { $ocena = "0 opinni"; } $href = $product->find("li.name a", 0)->href; $options[] = "<option value='" . $href . "'>" . $name . "<br/>" . strip_tags($ocena) . "</option>"; } return $options; } else { $products = $element->find("h1.name", 0); if (is_object($products)) { return $element->find("meta", 2)->content; } else { return ""; } } return ""; }