} } }

    哄骗curl抓取长途页面内容

    添加时间:2013-7-22 点击量:

    最根蒂根基的操纵如下



    ¥curlPost = a=1&b=2;//模仿POST数据
    
    ¥ch = curl_init();
    curl_setopt(
    ¥ch, CURLOPT_HTTPHEADER, array(X-FORWARDED-FOR:0.0.0.0, CLIENT-IP:0.0.0.0)); //机关IP
    curl_setopt(¥ch, CURLOPT_REFERER, http://www.baidu.com/); //机关来路
    curl_setopt(¥ch,CURLOPT_URL, http://www.baidu.com);//须要抓取的页面路径
    curl_setopt (
    ¥ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt (
    ¥ch, CURLOPT_TIMEOUT, 30);
    curl_setopt(
    ¥ch, CURLOPT_POSTFIELDS, ¥curlPost);//post值

    ¥file_contents = curl_exec(¥ch);//抓取的内容放在变量中
    curl_close(¥ch


    分享到: