|-原 自己用curl函数封装的一些采集函数
自己封装的一些采集函数,这里记录下 20200328 /** * () 13N2y19 1203 * @access public * @param $search_str 获取要搜索的字符串 * @return $contents 获取的网页内容 */ function curl_google($search_str){ $cookie_file = "google.txt"; $str_urlencode=urlencode($search_str); $url = "http://www.google.com/search?q={$str_urlencode}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); $contents = curl_exec($ch); curl_close($ch); return $contents; } function curl_baidu($search_str,$pn){ if(isset($pn)===false){ $pn=0; } $cookie_file = "baidu.txt"; $search_str=iconv('utf-8','gbk',$search_str); $str_urlencode=urlencode($search_str); $url="http://www.baidu.com/s?wd={$str_urlencode}&pn={$pn}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); $contents = curl_exec($ch); $contents=iconv('gbk','utf-8',$contents); curl_close($ch); return $contents; } function curl_baiduzhidao($search_str,$pn,$sort){ if(isset($pn)===false){ $pn=0; } if(isset($sort)===false){ $sort=0; } $cookie_file = "baidu.txt"; $search_str=iconv('utf-8','gbk',$search_str); $str_urlencode=urlencode($search_str); $url="http://zhidao.baidu.com/search?word={$search_str}&lm=0&rn=10&sort={$sort}&ie=gbk&pn={$pn}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); $contents = curl_exec($ch); $contents=iconv('gbk','utf-8',$contents); curl_close($ch); return $contents; } function curl_mtimeid_moviedetails($mtime_id){ $cookie_file = "mtime.txt"; $url="http://movie.mtime.com/{$mtime_id}/details.html#menu"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_se自己封装的一些采集函数,这里记录下 20200328 /** * () 13N2y19 1203 * @access public * @param $search_str...
浏览更多内容请先登录。
立即注册
更新于:2020-03-28 12:53:08
相关内容
WEB技术
WEB技术之前端技术
WEB技术之后端技术
WEB应用转手机APP,手机APP制作平台推荐
WEB应用与手机APP
Android相关
2017 年 Web 开发工程师技术发展路线图
session:手动删除客户端上的所有cookie,再次访问的时候为什么还是登录状态?
WEB技术之前端技术2
curl超时的设置
Yii2项目个人整理(因Github访问不稳定,自己整理下,方便用)
Yii2项目yii-starter-kit/yii2-starter-kit
安装中文版的opencart-v37报错
OpenCart 中文版/外贸版(代码各种坑,安装半天没安装上)
Feehi_CMS一款让人很舒服的Yii2应用,适合企业建站等CMS建站
rageframe2基于Yii2
推荐内容