|-原 Curl类采集,之前网上找的
之前网上找的别人写的专门用来采集的类,封装了php的curl 20200328 class cURL { var $headers; var $user_agent; var $compression; var $cookie_file; var $proxy; /** * 初始化 * * @param string $cookies * @param string $cookie * @param string $compression * @param string $proxy */ function cURL($cookies = TRUE, $cookie = 'cookies.txt', $compression = 'gzip', $proxy = '') { $this->headers [] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg'; $this->headers [] = 'Connection: Keep-Alive'; $this->headers [] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $this->user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)'; $this->compression = $compression; $this->proxy = $proxy; $this->cookies = $cookies; if ($this->cookies == TRUE) $this->cookie ( $cookie ); } /** * 配置cookie * * @param unknown $cookie_file */ function cookie($cookie_file) { if (file_exists ( $cookie_file )) { $this->cookie_file = $cookie_file; } else { fopen ( $cookie_file, 'w' ) or $this->error ( 'The cookie file could not be opened. Make sure this directory has the correct permissions' ); $this->cookie_file = $cookie_file; fclose ( $this->cookie_file ); } } /** * get方式打开页面 * * @param unknown $url * @return mixed */ function get($url) { $process = curl_init ( $url ); curl_setopt ( $process, CURLOPT_HTTPHEADER, $this->headers ); curl_setopt ( $process, CURLOPT_HEADER, 0 ); curl_setopt ( $process, CURLOPT_USERAGENT, $this->user_agent ); if ($this->cookies == TRUE) c之前网上找的别人写的专门用来采集的类,封装了php的curl 20200328 class cURL { var $headers; var $user_agent; v...
浏览更多内容请先登录。
立即注册
更新于:2020-03-28 12:50:12
相关内容
WEB技术
WEB技术之前端技术
WEB技术之后端技术
WEB应用转手机APP,手机APP制作平台推荐
WEB应用与手机APP
Android相关
2017 年 Web 开发工程师技术发展路线图
session:手动删除客户端上的所有cookie,再次访问的时候为什么还是登录状态?
WEB技术之前端技术2
curl超时的设置
推荐内容