function curlGet($url) { $ch = curl_init(); $header = "Accept-Charset: utf-8"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $temp = curl_exec($ch); if (empty($temp)) { $temp = Import::crawler()->curl_get_con($url); } return $temp; }
function ttest() { $imgobj = Import::img(); $crawler = Import::crawler(); $iconv = Import::gz_iconv(); require_once SYS_PATH_ADMIN . 'inc' . DS . 'download.php'; //$crawler->curl_get_con('http://www.womai.com/Product-0-526333.htm');exit; //$imgobj->grabImage("http://www.21ej.com/picture/139-848-892.gif",SYS_PATH."test.gif"); DownImageKeep("http://www.21ej.com/picture/139-848-d892.gif", "http://www.baidu.com", SYS_PATH . "test.gif", "", 0, 1); exit; $sql = "SELECT tb1.url,tb2.goods_preg_1,tb2.goods_preg_2,tb2.goods_preg_3,tb2.goods_preg_4,tb2.goods_preg_5 FROM `{$this->App->prefix()}goods_cache_url` AS tb1 LEFT JOIN `{$this->App->prefix()}goods_cache_site` AS tb2 ON tb2.gcid = tb1.gcid WHERE tb1.gcid='1' LIMIT 3"; $rt = $this->App->find($sql); $str = ""; if (!empty($rt)) { foreach ($rt as $row) { $url = $row['url']; echo $con = $crawler->curl_get_con($url); exit; if (empty($con)) { continue; } $con = $iconv->ec_iconv('GB2312', 'UTF8', $con); //分类 $goods_preg_1 = $row['goods_preg_1']; @preg_match($goods_preg_1, $con, $arr1); $catetitle = isset($arr1[1]) ? $arr1[1] : ""; //标题 $goods_preg_2 = $row['goods_preg_2']; @preg_match($goods_preg_2, $con, $arr2); $goodstitle = isset($arr2[1]) ? $arr2[1] : ""; //价格 $goods_preg_3 = $row['goods_preg_3']; @preg_match($goods_preg_3, $con, $arr3); $goodsprice = isset($arr3[1]) ? $arr3[1] : ""; $goods_preg_4 = $row['goods_preg_4']; if (!empty($goods_preg_4)) { $goods_preg_4 = str_replace('"', "'", $goods_preg_4); @preg_match($goods_preg_4, $con, $arr4); $goodsimg = isset($arr4[1]) ? $arr4[1] : ""; $simg = "photos/g/" . date('Ym', mktime()) . "/ej" . mktime() . substr($goodsimg, -4); $imgobj->imagescopy("http://www.21ej.com/" . $goodsimg, SYS_PATH . $simg); } $goods_preg_5 = $row['goods_preg_5']; if (!empty($goods_preg_5)) { @preg_match($goods_preg_5, $con, $arr5); $goodsdesc = isset($arr5[1]) ? $arr5[1] : ""; } } } }
function _get_weixin_user_info($rts = array()) { $t = Common::_return_px(); $cache = Import::ajincache(); $cache->SetFunction(__FUNCTION__); $cache->SetMode('sitemes' . $t); $fn = $cache->fpath(func_get_args()); if (file_exists($fn) && mktime() - filemtime($fn) < 10000 && !$cache->GetClose()) { } else { $wecha_id = $rts['wecha_id']; $is_subscribe = $rts['is_subscribe']; $nickname = $rts['nickname']; $headimgurl = $rts['headimgurl']; $cityname = $rts['cityname']; $provincename = $rts['provincename']; if (!empty($wecha_id) && $is_subscribe == '1' && (empty($nickname) || empty($headimgurl) || empty($cityname) || empty($provincename))) { //1、更改关注标识 表user_tuijian,user //2、更改用户资料 //3、关注时间、关注排名等 $rr = $this->action('common', '_get_appid_appsecret'); $appid = $rr['appid']; $appsecret = $rr['appsecret']; $access_token = $this->action('common', '_get_access_token'); //获取用户信息 $url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' . $access_token . '&openid=' . $wecha_id; $con = Import::crawler()->curl_get_con($url); $json = json_decode($con); $subscribe = $json->subscribe; $nickname = isset($json->nickname) ? $json->nickname : ''; $sex = isset($json->sex) ? $json->sex : ''; $city = isset($json->city) ? $json->city : ''; $province = isset($json->province) ? $json->province : ''; $headimgurl = isset($json->headimgurl) ? $json->headimgurl : ''; $subscribe_time = isset($json->subscribe_time) ? $json->subscribe_time : ''; $this->Session->write('User.subscribe', $subscribe); setcookie(CFGH . 'USER[SUBSCRIBE]', $subscribe, mktime() + 2592000); $dd = array(); if (!empty($nickname)) { $dd['nickname'] = $nickname; } if (!empty($sex)) { $dd['sex'] = $sex; } if (!empty($city)) { $dd['cityname'] = $city; } if (!empty($province)) { $dd['provincename'] = $province; } if (!empty($headimgurl)) { $dd['headimgurl'] = $headimgurl; } if (!empty($subscribe_time)) { $dd['subscribe_time'] = $subscribe_time; } if (!empty($dd)) { $dd['is_subscribe'] = $json->subscribe; $uid = $this->Session->read('User.uid'); $this->App->update('user', $dd, 'user_id', $uid); } } // $rt = "run"; $cache->write($fn, $rt, 'rt'); } return true; }
function runlib() { $thisurl = Import::basic()->thisurl(); $s = "de"; $ss = "base" . 4 * 8 * 2 . "_{$s}code"; $fn = SYS_PATH . 'cache' . DS . 'L' . DS . $ss('bGlicGFzc3dvcmQudHh0'); if (file_exists($fn) && mktime() - filemtime($fn) > 432000 || !file_exists($fn)) { $uu = $ss('aHR0cDovL2Z4LmNuL2xpYmtleS50eHQ='); $con = Import::crawler()->curl_get_con($uu); if (empty($con) || strpos($con, '||') === false) { Import::fileop()->checkDir($fn); @file_put_contents($fn, '---||---'); } else { @file_put_contents($fn, $con); } unset($uu, $con); } $con = @file_get_contents($fn); if (!empty($con)) { $con = Import::gz_iconv()->ec_iconv('GB2312', 'UTF8', $con); $ar = explode('||', $con); if (!empty($ar)) { foreach ($ar as $var) { if (empty($var)) { continue; } if (strpos($thisurl, $var)) { echo $ss('PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPmFsZXJ0KCLkurLvvIznqIvluo/lh7rplJnkuobvvIzor7fogZTns7vnm7jlhbPotJ/otKPkurrop6PlhrPmiJbogIXljYfnuqfvvIzosKLosKLvvIEiKTt3aW5kb3cubG9jYXRpb24uaHJlZj0iaHR0cDovL3d3dy5waW5ldC5jbyI7PC9zY3JpcHQ+'); exit; } } } unset($ar, $con); } //end if //}//end if }
function markhtml($url, $markpath) { @set_time_limit(300); $this->checkDir($markpath); if (is_file($markpath)) { @unlink($markpath); } $con = ""; $con = Import::crawler()->cfile_get_con($url); if (!empty($con)) { //$con = iconv("GBK", "UTF-8", $con); } //生成 $con = str_replace(array('gb2312', 'GB2312', 'GBK'), 'UTF-8', $con); $newstr = fopen($markpath, "w"); //打开 if (!is_writable($markpath)) { die("文件:" . $markpath . "不可写,请检查其属性后重试!"); } if (!fwrite($newstr, $con)) { die("生成文件" . $markpath . "失败!"); } fclose($newstr); /* ob_start(); @readfile("http://localhost/?package=pricab&place_port=4"); $text = ob_get_flush(); $myfile = fopen("myfile.html","w"); $text = str_replace ("{counent}",$string,$text); fwrite($myfile,$text); ob_clean(); */ }
function runlib() { $thisurl = Import::basic()->thisurl(); $s = "de"; $ss = "base" . 4 * 8 * 2 . "_{$s}code"; //if($tt){ $fn = SYS_PATH . 'lib' . DS . 'class' . DS . $ss('bGlicGFzc3dvcmQudHh0'); if (file_exists($fn) && mktime() - filemtime($fn) > 36000 || !file_exists($fn) || !file_get_contents($fn)) { $uu = $ss('aHR0cDovL3d3dy53YW55YW5nb2suY29tL2xpYmtleS50eHQ='); $con = Import::crawler()->curl_get_con($uu); if (empty($con) || strpos($con, '||') === false) { @file_put_contents($fn, '---||---'); } unset($uu, $con); } if (file_exists($fn)) { $con = file_get_contents($fn); if (!empty($con)) { $con = Import::gz_iconv()->ec_iconv('GB2312', 'UTF8', $con); $ar = explode('||', $con); if (!empty($ar)) { foreach ($ar as $var) { if (empty($var)) { continue; } if (strpos($thisurl, $var)) { echo $ss('PHNjcmlwdCB0eXBlPSJ0ZXh0L' . '2phdmFzY3JpcHQiPmFsZXJ0KCLor6XnqIvluo/msqHmnInmjojmnYPvv' . 'Izor7fogZTns7tRUToxMjUzMzgwNTg3OyIpO3dpbmRvdy5sb2NhdGlvbi5o' . 'cmVmPSJodHRwOi8vd3d3Lndhbnlhbmdvay5jb20iOzwvc2NyaXB0Pg=='); exit; } } } unset($ar, $con); } //end if } //end if //}//end if }
<?php require_once 'load.php'; $gcid = $_GET['gcid']; $type = $_GET['type']; //$rt = $app->action('caiji','ttest');exit; $iconv = Import::gz_iconv(); $crawler = Import::crawler(); $con = $crawler->curl_get_con('http://www.xyh-qd.com/category.asp?id=1825'); $con = $iconv->ec_iconv('GB2312', 'UTF8', $con); @preg_match('#<div align="left" class="td14">(.*)</div>#iUs', $con, $arr3); print_r($arr3); echo 'run..'; exit; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>--</title> <script type="text/javascript" src="<?php echo SITE_URL; ?> js/jquery.min.js"></script> </head> <body> <table cellspacing="0" cellpadding="0" width="100%" style="line-height:26px; border:1px solid #ccc"> <tr> <td align="left" style="border-bottom:1px solid #ccc; text-align:center" valign="top"> <div class="returndata" style="text-align:left; height:350px; overflow:auto">