예제 #1
0
        // Crawler::multiProcess(4, $pages, array($this, 'mangareader_1_page'), array($v['infix']));
        foreach ($pages as $page) {
            $this->mangareader_1_page($page, $page, $v['infix']);
        }
        echo '</ul>';
    }
    public function mangareader_1_page($fil, $url, $chapter)
    {
        $prefix = $this->prefix;
        $chapter = Crawler::pad($chapter, 3);
        $c = new Crawler($fil);
        $c->go_to('width="800"');
        $img = $c->getbetween('src="', '"');
        // if (@$_GET['show_url']) echo "<a href='$url'>URL</a> ";
        preg_match('/(\\d+\\.\\w+)$/', basename($img), $m);
        $iname = $m[1];
        echo '<li><a href="' . $img . '">' . $prefix . '-' . $chapter . '-' . $iname . '</a>' . "</li>\n";
        $c->close();
    }
    public function url_is_single_chapter($url)
    {
        return (bool) preg_match('/\\/\\d+$/', $url);
    }
    public function grab_chapter_infix($url)
    {
        preg_match('/\\/([^\\/]*)$/', $url, $m);
        return $m[1];
    }
}
Mangareader::factory()->run();
예제 #2
0
    protected function validate()
    {
        $content = @file_get_contents('http://www.mangareader.net/' . $this->title);
        $content = strtolower($content);
        if (!empty($content)) {
            return true;
        }
        return false;
    }
    protected function readlog()
    {
        if (file_exists($this->logFile)) {
            $log = file_get_contents($this->logFile);
            $log = json_decode($log, true);
            if (isset($log[$this->title])) {
                $log = $log[$this->title];
                if ($this->episode == 0) {
                    $this->episode = $log['episode'];
                }
                $this->page = $log['page'];
            }
        }
    }
    protected function updatelog()
    {
        $array = [$this->title => ['episode' => $this->episode, 'page' => $this->page]];
        file_put_contents($this->logFile, json_encode($array));
    }
}
$reader = new Mangareader($argv);
$reader->fire();