• 技术文章 >后端开发 >php教程

    使用curl库通过代理服务器访问网页_PHP

    2016-06-01 12:34:50原创768
    代理服务器

    function curl_string ($url,$user_agent,$proxy){

    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_PROXY, $proxy);
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt");
    curl_setopt ($ch, CURLOPT_HEADER, 1);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
    $result = curl_exec ($ch);
    curl_close($ch);
    return $result;

    }

    $url_page = "http://www.366edu.net";
    $user_agent = "Mozilla/4.0";
    $proxy = "http://192.11.222.124:8000";
    $string = curl_string($url_page,$user_agent,$proxy);
    echo $string;
    ?>
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:php如何隐藏图片的真实地址_PHP 下一篇:php模板smarty_PHP
    PHP编程就业班

    相关文章推荐

    • 浅析PHP配置文件中的几种超时配置• 聊聊nginx平滑重启和FPM平滑重启• 归纳总结PHP对象基础• 请问疑难杂症 • 求这个网站的基本词挖掘功能的做法,求实现代码

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网