php使用curl通過代理獲取數(shù)據(jù)的實(shí)現(xiàn)方法
來源:易賢網(wǎng) 閱讀:1951 次 日期:2016-08-22 15:09:07
溫馨提示:易賢網(wǎng)小編為您整理了“php使用curl通過代理獲取數(shù)據(jù)的實(shí)現(xiàn)方法”,方便廣大網(wǎng)友查閱!

本文實(shí)例講述了php使用curl通過代理獲取數(shù)據(jù)的實(shí)現(xiàn)方法。分享給大家供大家參考,具體如下:

$curl=curl_init();

curl_setopt($curl, CURLOPT_URL, "http://www.baidu.com/");

curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0');

curl_setopt($curl, CURLOPT_REFERER, 'http://www.guahao.com/');

curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($param));

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true);

curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);

curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);

curl_setopt($curl, CURLOPT_PROXY, "180.186.11.121");

curl_setopt($curl, CURLOPT_PROXYPORT, "37211");

curl_setopt($curl, CURLOPT_PROXYUSERPWD, "taras:taras-ss5");

$result=curl_exec($curl);

希望本文所述對大家PHP程序設(shè)計(jì)有所幫助。

更多信息請查看網(wǎng)絡(luò)編程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn)

版權(quán)所有:易賢網(wǎng)