function getItemInfo($url) { $this->debug("Loading {$url}..."); $contents = $this->loadPage($url); $pattern = '{ <b> Почтовый адрес </b> <br> <div class="compinfo">(.+?)</div> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $address = $matches[1]; } else { $address = ""; } $pattern = '{ <b> Телефон </b> <br> <div class="compinfo">(.+?)</div> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { list($phone, $fax) = $this->getPhone($matches[1]); } else { $phone = ""; $fax = ""; } $pattern = '{ <b> Адрес в интернете </b> <br> <div class="compinfo">(.+?)</div> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $site = $matches[1]; } else { $site = ""; } // TODO Get "metro" $metro = ""; $pattern = '{ <b> E-mail </b> <br> <a[^>]+>.*?<img src="(http://img.yp.ru/emails/[^"]+)"[^>]*> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $email = $matches[1]; } else { $email = ""; } $pattern = '{ <div[^>]+> Рубрики </div>.+? <div class="blocklist"> (.+?) <div class="blocklist"> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $rubrics = $this->getRubrics($matches[1]); } else { $rubrics = array(); } $res = StrUtils::cleanStringsArray(array("address" => $address, "phone" => $phone, "fax" => $fax, "metro" => $metro, "site" => $site, "email" => $email)); $res["rubrics"] = $rubrics; return $res; }
function getItemInfo($url) { $this->debug("Loading {$url}..."); $contents = $this->loadPage($url); $pattern = '{ <div[^>]+> Почтовый адрес.+?</div> <div[^>]+>(.+?)</div> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $address = $matches[1]; } else { $address = ""; } $pattern = '{ <div[^>]+> Телефон: </div> <div[^>]+>(.+?)</div> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { list($phone, $fax) = $this->getPhone($matches[1]); } else { $phone = ""; $fax = ""; } $pattern = '{ <div[^>]+> Адрес в интернете: </div> <div[^>]+>(.+?)</div> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $site = $matches[1]; } else { $site = ""; } $pattern = '{ <div[^>]+> Метро: </div> (.+?) <div class="sqblockhalf"[^>]*> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $metro = $matches[1]; } else { $metro = ""; } $pattern = '{ <div[^>]+> E-mail: </div> <div[^>]+>.+?<img[^>]+src="(http://img.yp.ru/emails/[^"]+)"[^>]*> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $email = $matches[1]; } else { $email = ""; } $pattern = '{ <h2[^>]+> Рубрики </h2>.+? <table[^>]+> (.+?) </table> }si'; $pattern = preg_replace("{\\s+}", "\\s*", $pattern); if (preg_match($pattern, $contents, $matches)) { $rubrics = $this->getRubrics($matches[1]); } else { $rubrics = array(); } $res = StrUtils::cleanStringsArray(array("address" => $address, "phone" => $phone, "fax" => $fax, "metro" => $metro, "site" => $site, "email" => $email)); $res["rubrics"] = $rubrics; return $res; }