PHP CURL 使用代理访问服务器
生活随笔
收集整理的這篇文章主要介紹了
PHP CURL 使用代理访问服务器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用CURL庫訪問代理服務器
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.google.com"; $user_agent = "Mozilla/4.0"; $proxy = "http://192.11.222.124:8000"; $string = curl_string($url_page,$user_agent,$proxy); echo $string;上面的代碼如果不好用 請用下面的代碼
?
$proxy = "80.25.198.25"; $proxyport = "8080"; $ch = curl_init("http://sfbay.craigslist.org/");curl_setopt($ch, curlOPT_RETURNTRANSFER,1); curl_setopt($ch,curlOPT_proxy,$proxy); curl_setopt($ch,curlOPT_proxyPORT,$proxyport); curl_setopt ($ch, CURLOPT_TIMEOUT, 120);$result = curl_exec($ch); echo $result;curl_close($ch);?
轉載于:https://www.cnblogs.com/misoag/archive/2013/02/18/2915926.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的PHP CURL 使用代理访问服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何从操作系统安装文件提取驱动文件/ H
- 下一篇: 记录下Lambda常用的表现形式