public function updateBookList($fromPage = 1) { $page = $fromPage; $maxPage = 0; do { $html = PtHttpCk101::getBookListPage($page); $bookList = PtParserCk101::parseBooksFromForum($html); $maxPage = max($maxPage, PtParserCk101::parseForumPages($html)); $this->d("parsing forum page {$page}/{$maxPage}"); $this->updateBookListImpl($bookList); $this->d("update list finish " . count($bookList) . " books"); sleep(self::QUERY_SLEEP); } while (++$page <= $maxPage); }
public function testParserBooksFromForum() { //$html = file_get_html("test/forum.html"); // new version 2016/01/20 update $search = "</span>\r\n </div>"; $replace = "</span>\r\n"; $htmlText = str_replace($search, $replace, file_get_contents("test/forum.html")); $html = str_get_html($htmlText); $r = PtParserCk101::parseBooksFromForum($html); //print_r($r); }