} else {
                 if (preg_match('/月/', $published_at)) {
                     $published_at = preg_replace('/(月|日)/', '-', $published_at);
                     $published_at = trim($published_at, ' -');
                     $published_at = $year . '-' . $published_at . ' 00:00:00';
                     $published_at = strtotime($published_at);
                 }
             }
             date_default_timezone_set($original_timezone);
             $thumbnail = $article->find('.img_box2 img')[0]->src;
             /** check if we have this article crawled alread, if yes, skip **/
             $wechat_article = WechatArticle::findByCombo($bizid, $mid, $idx);
             if ($wechat_article) {
                 continue;
             }
             $wechat_article = new WechatArticle();
             $wechat_article->setAccountId($wechat_account->getId());
             $wechat_article->setBizId($bizid);
             $wechat_article->setMid($mid);
             $wechat_article->setIdx($idx);
             $wechat_article->setTitle($title);
             $wechat_article->setPublishedAt($published_at);
             $wechat_article->setThumbnail($thumbnail);
             $wechat_article->setUrl($url);
             $wechat_article->save();
         }
         $dom->clear();
     }
     $i++;
 } else {
     continue;
Example #2
0
if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "wechat_account")) {
    //- create tables if not exits
    echo " - Create table 'wechat_account' ";
    echo WechatAccount::createTableIfNotExist() ? "success\n" : "fail\n";
}
//-- WechatArticle:Clear cache
if ($command == "cc") {
    if ($arg1 == "all" || $arg1 == "wechat_account") {
        echo " - Drop table 'wechat_article' ";
        echo WechatArticle::dropTable() ? "success\n" : "fail\n";
    }
}
//-- WechatArticle:Import DB
if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "wechat_article")) {
    //- create tables if not exits
    echo " - Create table 'wechat_article' ";
    echo WechatArticle::createTableIfNotExist() ? "success\n" : "fail\n";
}
//-- WechatAccountUser:Clear cache
if ($command == "cc") {
    if ($arg1 == "all" || $arg1 == "wechat_account") {
        echo " - Drop table 'wechat_account_user' ";
        echo WechatAccountUser::dropTable() ? "success\n" : "fail\n";
    }
}
//-- WechatAccountUser:Import DB
if ($command == "import" && $arg1 == "db" && (is_null($arg2) || $arg2 == "wechat_account_user")) {
    //- create tables if not exits
    echo " - Create table 'wechat_account_user' ";
    echo WechatAccountUser::createTableIfNotExist() ? "success\n" : "fail\n";
}