コード例 #1
0
ファイル: 77nt.php プロジェクト: guozanhua/bookspider
 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;
 }
コード例 #2
0
ファイル: bengou.php プロジェクト: guozanhua/bookspider
 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;
 }
コード例 #3
0
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;
}
コード例 #4
0
ファイル: imanhua.php プロジェクト: guozanhua/bookspider
 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;
 }
コード例 #5
0
ファイル: ysts8.php プロジェクト: guozanhua/bookspider
 function GetChapters($bookid)
 {
     $uri = "http://www.ysts8.com/Yshtml/Ys" . $bookid . ".html";
     $html = $this->http->get($uri, "Ysjs/bot.js");
     $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html);
     $xpath = new XPath($html);
     $infos = $xpath->query("//div[@class='ny_txt']/ul/p");
     $elements = $xpath->query("//div[@class='ny_l']/ul/li/a[1] | //div[@class='zxwz']/ul/li/a[1]");
     $summary = "";
     foreach ($infos as $info) {
         foreach ($info->childNodes as $node) {
             if (XML_TEXT_NODE == $node->nodeType) {
                 $summary = $summary . $node->nodeValue;
                 $summary = $summary . "\r\n";
             }
         }
     }
     $chapters = array();
     if (!is_null($elements)) {
         foreach ($elements as $element) {
             $href = $element->getattribute('href');
             $name = $element->nodeValue;
             if (strlen($href) > 0 && strlen($name) > 0) {
                 $chapterid = basename($href, ".html");
                 list($play, $bookid, $dir1, $dir2, $chapter) = explode("_", $chapterid);
                 if ((int) $dir1 > 99999 || (int) $dir2 > 9 || (int) $chapter > 9999) {
                     print_r("invalid chapter: {$chapterid}\n");
                     die;
                 }
                 $chapterid = sprintf("%05d%d%04d", (int) $dir1, (int) $dir2, (int) $chapter);
                 $chapters[] = array("name" => $name, "uri" => $chapterid);
             }
         }
     }
     $data = array();
     $data["icon"] = "";
     $data["info"] = $summary;
     $data["chapter"] = $chapters;
     $data["catalog"] = $xpath->get_value("//div[@id='i']/h3");
     $data["subcatalog"] = $xpath->get_value("//div[@id='i']/h2");
     return $data;
 }
コード例 #6
0
ファイル: xxbh.php プロジェクト: guozanhua/bookspider
 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;
 }