public function actionQueue() { header('Access-Control-Allow-Origin:*'); $url = trim($this->post("url", "")); if (!$url) { return $this->renderJSON([], 'no illage param url ~~', -1); } $ret = EmoticonService::addQueue(['url' => $url]); if (!$ret) { return $this->renderJSON([], EmoticonService::getLastErrorMsg(), -1); } return $this->renderJSON(); }
/** * 每天运行一次就ok了 * php yii emoticon/scrapy/weixin18 */ public function actionWeixin18($page = 1) { $host = 'http://www.18weixin.com'; $url = $host . '/weixinbiaoqing_%s.shtml'; $url = sprintf($url, $page); $content = HttpClient::get($url); $content = mb_convert_encoding($content, 'gb2312', 'utf-8'); $html_dom = new \HtmlParser\ParserDom($content); $img_wrap_array = $html_dom->find('div.imgborder_bqimg_width'); if (!$img_wrap_array) { return $this->echoLog("error:no img tag ~~"); } foreach ($img_wrap_array as $_item) { $tmp_target_url = $_item->find("a", 0); $tmp_target_url = $host . $tmp_target_url->getAttr("href"); EmoticonService::addQueue(['url' => $tmp_target_url, 'type' => 2]); } return $this->echoLog("it's over ~~"); }