function GetChapters($bookid) { list($path, $id) = split("-", $bookid); $uri = "http://www.77nt.com/" . $path . "/List_ID_" . $id . ".html"; $html = http_get($uri); $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html); $xpath = new XPath($html); $iconuri = $xpath->get_attribute("//div[@class='conlist']/ul/li/img", "src"); $summary = $xpath->get_value("//ul[@class='introbox']/p/span"); $elements = $xpath->query("//ul[@class='compress']/ul/div/li/span/a"); $host = parse_url($uri); $iconuri = 'http://' . $host["host"] . $iconuri; $chapters = array(); foreach ($elements as $element) { $href = $element->getattribute('href'); $chapter = $element->nodeValue; if (strlen($href) > 0 && strlen($chapter) > 0) { $chapters[] = array("name" => $chapter, "uri" => 'http://' . $host["host"] . $href); } } $data = array(); $data["icon"] = $iconuri; $data["info"] = $summary; $data["chapter"] = $chapters; return $data; }
function GetFrameSrc($bookid, $chapterid) { global $http; $uri = sprintf('http://www.ysts8.com/down_%d_%d_%d_%d.html', $bookid, (int) ($chapterid / 100000), (int) ($chapterid / 10000) % 10, (int) ($chapterid % 10000)); //$html = http_proxy_get($uri, "Ysjs/bot.js", 10); $html = $http->get($uri); $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html); if (strlen($html) < 1) { return ""; } $xpath = new XPath($html); $src = $xpath->get_attribute("//iframe[1]", "src"); // "/play/flv.asp?url=http%3A%2F%2F180e%2Eysx8%2Enet%3A8000%2F%D0%FE%BB%C3%D0%A1%CB%B5%2F2009%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB003%2Emp3&jiidx=/play%5F1836%5F49%5F1%5F4%2Ehtml&jiids=/play%5F1836%5F49%5F1%5F2%2Ehtml&id=1836&said=49" // "/play/flv_down.asp?wtid=http%3A%2F%2F180e%2Dd%2Eysts8%2Ecom%3A8000%2F%D0%FE%BB%C3%D0%A1%CB%B5%2F2009%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB001%2Emp3&ctid=http%3A%2F%2F163e%2Dd%2Eysts8%2Ecom%3A8000%2F%D0%FE%BB%C3%D0%A1%CB%B5%2F2009%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB001%2Emp3&title=%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB&ji=1&id=1836&said=49" return "http://www.ysts8.com" . $src; }
function GetBook($bookid) { //$uri = "http://www.bengou.cm/cartoon/douluodalu/"; list($bname, $bid) = explode("_", $bookid); $uri = sprintf('http://bengou.cm/cartoon/%s/', $bname); $html = $this->http->get($uri, "email.gif"); $html = str_replace("<head>", '<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />', $html); if (strlen($html) < 1) { return False; } $sections = array(); $xpath = new XPath($html); $elements = $xpath->query("//div[@class='section-list mark']"); foreach ($elements as $element) { $chapters = array(); $nodes = $xpath->query("span/a", $element); foreach ($nodes as $node) { $href = $node->getattribute("href"); $name = $node->nodeValue; //http://bengou.cm/cartoon/xiudougaoxiao/7278_134945.html list($bid, $cid) = explode("_", basename($href, ".html")); $chapters[] = array("name" => $name, "id" => $cid); } $section = array(); $section["name"] = $xpath->get_value("h6", $element); $section["chapters"] = $chapters; $sections[] = $section; } $datetime = $xpath->get_value("//div[@class='cartoon-intro']/div/p[6]"); list($year, $mon, $day, $h, $m, $s) = sscanf($datetime, "更新时间:%d/%d/%d %d:%d:%d"); $book = array(); $book["icon"] = $xpath->get_attribute("//div[@class='cartoon-intro']/a/img", "src"); $book["author"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[1]/a"); $book["status"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[2]"); $book["catalog"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[3]"); $book["tags"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[4]"); $book["region"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[5]/a"); $book["datetime"] = date("Y-m-d H:i:s", mktime($h, $m, $s, $mon, $day, $year)); $book["summary"] = $xpath->get_value("//p[@id='cartoon_digest2']"); $book["section"] = $sections; return $book; }
function __WebGetBookInfo($bookid) { global $http; $uri = "http://www.pingshu8.com/MusicList/mmc_{$bookid}.htm"; $referer = "Referer: http://www.pingshu8.com/top/xiangsheng.htm"; $html = $http->get($uri, "*****@*****.**", array("referer" => $referer)); $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html); if (strlen($html) < 1) { return False; } $host = parse_url($uri); $xpath = new XPath($html); $value = $xpath->get_value("//div[@class='list5']/div"); $selects = $xpath->query("//select[@name='turnPage']/option"); $iconuri = $xpath->get_attribute("//div[@class='a']/img", "src"); $data = array(); if (0 == strncmp("../", $iconuri, 3)) { $data["icon"] = 'http://' . $host["host"] . dirname(dirname($host["path"])) . '/' . substr($iconuri, 3); } else { $data["icon"] = 'http://' . $host["host"] . dirname($host["path"]) . '/' . $iconuri; } list($count) = sscanf($value, " 共有%d集"); $data["info"] = $xpath->get_value("//div[@class='c']/div"); $data["page"] = $selects->length; $data["count"] = $count; $data["chapter"] = __ParseChapter($html); $data["catalog"] = $xpath->get_value("//div[@class='t1']/div/a[2]"); $data["subcatalog"] = $xpath->get_value("//div[@class='t1']/div/a[3]"); return $data; }
function GetBook($bookid) { $uri = "http://www.imanhua.com/comic/{$bookid}/"; $html = $this->http->get($uri, 'foot.js'); $html = str_replace("charset=gb2312", "charset=gb18030", $html); if (strlen($html) < 1) { return False; } // file_put_contents("imanhua-$bookid.html", $html); $xpath = new XPath($html); $icon = $xpath->get_attribute("//div[@class='bookCover']/img | //div[@class='fl bookCover']/img", "src"); $summary = ""; $elements = $xpath->query("//div[@class='intro']/p"); foreach ($elements as $element) { $text = $element->nodeValue; $summary = $summary . $text . "\r\n"; } $elements = $xpath->query("//div[@class='chapterList']/ul/li/a"); if ($elements->length < 1) { $elements = $xpath->query("//ul[@id='subBookList']/li/a"); } $chapters = array(); foreach ($elements as $element) { $href = $element->getattribute('href'); $chapter = $element->getattribute('title'); if (strlen($href) > 0 && strlen($chapter) > 0) { $chapters[] = array("name" => $chapter, "uri" => 'http://www.imanhua.com' . $href); } } $header = $xpath->get_value("//p[@class='cf bookAttr'] | //p[@class='bookAttr']"); $headers = explode("|", $header); if (4 != count($headers)) { print_r("GetBook({$bookid}): get bookAttr failed.\n"); die; } // 完结状态:[ 连载中 ] 原作者:尾田荣一郎 | 字母索引:A | 加入时间:2007-04-30 | 更新时间:2014-08-20 $author = substr($headers[0], strpos($headers[0], "原作者:") + strlen("原作者:")); $intime = substr($headers[2], strpos($headers[2], "加入时间:") + strlen("加入时间:")); $uptime = substr($headers[3], strpos($headers[3], "更新时间:") + strlen("更新时间:")); $status = strcmp("连载中", substr($headers[0], strpos($headers[0], "完结状态:[ ") + strlen("完结状态:[ "))); $book = array(); $book["icon"] = "http://www.imanhua.com" . $icon; $book["author"] = trim($author); $book["status"] = $status; $book["catalog"] = ""; $book["tags"] = ""; $book["region"] = ""; $book["datetime"] = $uptime . " 00:00:00"; // "Y-m-d H:i:s"; $book["summary"] = $summary; $book["section"] = array("name" => "", "chapters" => $chapters); return $book; }
function GetAudio2($bookid, $chapter, $uri) { $html = http_proxy_get($uri, "Ysjs/bot.js", 10); $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html); $headers = array("Referer: " . $uri); $xpath = new XPath($html); $uri = $xpath->get_attribute("//iframe[1]", "src"); $html = http_proxy_get('http://www.ysts8.com/' . $uri, "www.ysts8.com", 20, "proxy.cfg", $headers); //file_put_contents ("a.html", $html); // 6102986163870x1406030845x6103448776624-5be9cd2016294cd6a07a0a063876fdbc if (!preg_match('/([0-9]+x140[0-9]{7}x[0-9]+)/', $html, $matches1)) { print_r("don't match time"); return ""; } if (!preg_match('/([0-9a-fA-F]{16,})/', $html, $matches2)) { print_r("don't match hash"); return ""; } if (2 == count($matches1)) { $postfix = $matches1[1]; } // if(strpos($html, "jp-jplayer") == false){ // $uri = $xpath->get_attribute("//iframe[2]", "src"); // $html = http_proxy_get('http://www.ysts8.com/' . $uri, "www.ysts8.com", 20, "proxy.cfg", $headers); // } //file_put_contents ("a.html", $html); // if(preg_match('/url2.*=.*\'(.*?)\';/', $html, $matches1)){ // if(2 == count($matches1)){ // $uri = $matches1[1]; // } // } $arr = explode("&", $uri); $arr = explode("?", $arr[0]); $arr = explode("=", $arr[1]); $uri = urldecode($arr[1]); $uri = iconv("gb18030", "UTF-8", $uri); //$t = time(); //$postfix = sprintf("?%ux%ux%u-f6441157ba03c991857d77880d9f9f9e", $t+218070220011, $t, $t+462612754+218070220011); return $uri . '?' . $postfix . '-' . $matches2[1]; //if(preg_match_all('/url2\+\'\?(.*?)\'/', $html, $matches)){ if (preg_match('/mp3\\:\'\'\\+(.*?)\\+\'(.*?)\'/', $html, $matches)) { //if(preg_match('/\+\'\?(.*?)\'/', $html, $matches)){ if (3 == count($matches)) { print_r($matches[1]); print_r($matches[2]); //$arr = explode("$$$", $uri); //$pos = strpos($arr[0], "?"); //$uri = substr($arr[0], $pos+1); $uri = $uri . '?' . $matches[1]; //$uri = $matches[1]; //return $uri; return iconv("gb18030", "UTF-8", $uri); } } return ""; }
function GetBooks($uri) { $uri = 'http://www.xxbh.net' . $uri; $html = http_proxy_get($uri, "template/xxbh", 10); $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html); $xpath = new XPath($html); $books = array(); if (0 == strcmp($uri, 'http://www.xxbh.net/comicone/page_a.html')) { $elements = $xpath->query("//ul[@class='ul222']/li"); foreach ($elements as $element) { $href = $xpath->get_attribute("a[2]", "href", $element, ""); $book = $xpath->get_attribute("a/img", "alt", $element, ""); $icon = $xpath->get_attribute("a/img", "src", $element, ""); $time = $xpath->get_value("em", $element, ""); $status = $xpath->get_value("b", $element, ""); if (strlen($href) > 0 && strlen($book) > 0) { $bookid = basename($href); $books[$bookid] = array("bookid" => $bookid, "book" => $book, "icon" => $icon, "time" => $time, "status" => $status); } } } else { if (0 == strcmp($uri, 'http://www.xxbh.net/comicone/page_b.html')) { $elements = $xpath->query("//ul[@class='ul_list']/li"); foreach ($elements as $element) { $book = $xpath->get_attribute("a", "title", $element, ""); $href = $xpath->get_attribute("a", "href", $element, ""); if (strlen($href) > 0 && strlen($book) > 0) { $bookid = basename($href); $books[$bookid] = array("bookid" => $bookid, "book" => $book); } } } else { $page = $xpath->get_attribute("//a[@id='k_2']", "href"); $page = (int) $page; for ($i = 1; $i <= $page; $i++) { if (1 != $i) { $u = $uri . "{$i}.html"; $html = http_proxy_get($u, "template/xxbh", 10); $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html); $xpath = new XPath($html); } $elements = $xpath->query("//ul[@class='ul222']/li"); foreach ($elements as $element) { $href = $xpath->get_attribute("a[2]", "href", $element, ""); $book = $xpath->get_attribute("a/img", "alt", $element, ""); $icon = $xpath->get_attribute("a/img", "src", $element, ""); $time = $xpath->get_value("em", $element, ""); $status = $xpath->get_value("b", $element, ""); if (strlen($href) > 0 && strlen($book) > 0) { $bookid = basename($href); $books[$bookid] = array("bookid" => $bookid, "book" => $book, "icon" => $icon, "time" => $time, "status" => $status); } } } } } $data = array(); $data["icon"] = ""; $data["book"] = $books; return $data; }