Beispiel #1
0
function GetFollowings($pages)
{
    global $cookie_file;
    $pages = 1;
    $followings = array();
    while (true) {
        Msg(0, "Page number is '{$pages}'.\n");
        $url = 'http://www.pixiv.net/bookmark.php?type=user&rest=show&p=' . $pages;
        list($html, $info) = @Curl($url, '');
        # 今見ているページのfollowingsを取得
        $q = '//section/div[ @class = "members" ]/ul/li/div[ @class = "usericon" ]/a';
        $res = HtmlParse($html, $q);
        if ($res->length != 0) {
            foreach ($res as $node) {
                $href = $node->getAttribute('href');
                //  srcは実際に表示されているとき
                $matchs = array();
                preg_match('/\\w+\\.\\w+\\?\\w+=(\\d+)/', $href, $matchs);
                array_push($followings, $matchs[1]);
            }
        } else {
            return false;
        }
        # 次のページありゅ?
        $q = '//section/div[ @class = "pages" ]/ol/li/a[ @rel = "next"]';
        // next page
        $res = HtmlParse($html, $q);
        if ($res->length == 2) {
            $pages = $pages + 1;
        } else {
            return $followings;
        }
    }
}
function NextArtWorkExist($artwork_id)
{
    $url = 'http://www.pixiv.net/member_illust.php?mode=medium&illust_id=' . $artwork_id;
    $log_file_name = 'next_artwork_id_' . $artwork_id;
    list($html, $info) = @Curl($url);
    // urlからcontentを引っ張ってくる
    $q = '//ul/li[ @class = "before" ]/a';
    // 次の作品
    $res = HtmlParse($html, $q);
    if ($res->length == 1) {
        // 次のページがあるとき
        foreach ($res as $node) {
            $matchs = array();
            // 次のillust_idを探す
            preg_match('/illust_id=(\\d+)/', $node->getAttribute("href"), $matchs);
            $next_artwork_id = $matchs[1];
        }
        return $next_artwork_id;
    } else {
        // 次のページがないとき
        Msg(0, "This artwork_id '" . $artwork_id . "' is the latest.\n");
        return $artwork_id;
        // 同じartwork_idを返す
    }
}