php curl请求转发
来源:互联网 发布:iptv和网络电视哪个好 编辑:程序博客网 时间:2024/05/17 01:29
<?php function get_url_content($url){ $user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"; $ch = curl_init(); //curl_setopt ($ch, CURLOPT_PROXY, $proxy); curl_setopt ($ch, CURLOPT_URL, $url);//设置要访问的IP curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);//模拟用户使用的浏览器 @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 ); // 使用自动跳转 curl_setopt ($ch, CURLOPT_TIMEOUT, 60); //设置超时时间 curl_setopt ($ch, CURLOPT_AUTOREFERER, 1 ); // 自动设置Referer curl_setopt ($ch, CURLOPT_COOKIEJAR, 'c:\cookie.txt'); curl_setopt ($ch, CURLOPT_HEADER,0); //显示返回的HEAD区域的内容 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 10); $result = curl_exec($ch); curl_close($ch); return $result; }print_r(get_url_content('http://www.baidu.com'));?>
-----------------------------------------------------------------------------------------
还可以用下面方式实现请求转发
print_r(file_get_contents('http://www.baidu.com'));
- php curl请求转发
- PHP 请求转发(CURL)
- PHP中实现请求转发(curl)和请求重定向
- 转发的 php curl 使用
- PHP - CURL 模拟请求
- PHP CURL 发送请求
- php curl请求
- php curl 批量请求
- PHP curl请求https
- php curl 请求
- php curl 接口请求
- PHP CURL 模拟请求
- PHP页面合成+请求转发
- PHP CURL发送POST请求
- php curl携带 cookie 请求
- php通过curl请求api
- PHP 的curl 请求https
- php curl 请求方法封装
- oracle脚本
- C++类型转换
- 支持不同屏幕尺寸——Supporting Different Screen Sizes
- hfs-delimited and lfs-delimited
- python手记(31)
- php curl请求转发
- (转载)Maven的安装、配置及使用入门
- 服务访问RTX服务 针对分开部署的情况
- adb connect 出现错误?这是怎么回事
- 【翻译】iOS Tech Talk:Michael Jruewitz谈性能测试
- 微信公众平台搭建与开发揭秘
- myeclipse 里面的server 配置的 tomcat 图标全部不见
- DelPhi6中出现 Can not find engine configuration file如何解决?
- NYOJ 588题 Money