首页 >php教程 >PHP源码 >php代理fanqiang

php代理fanqiang

PHP中文网
PHP中文网原创
2016-05-25 17:05:203268浏览

跳至

 array('timeout' => 5, 
	'proxy' => 'tcp://127.0.0.1:8118', 
	'request_fulluri' => True,) 
) 
); 
$result = file_get_contents($url, False, $ctx); 
echo $result; 

/*
//curl 使用
$ci = curl_init(); 
$url = "http://www.youtube.com";
curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, TRUE); 
curl_setopt($ci, CURLOPT_PROXY, '127.0.0.1:8118'); 
curl_setopt($ci, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); 
curl_setopt($ci, CURLOPT_URL, $url); 
curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1);  
echo "starting...";
$response = curl_exec($ci);
curl_close($ci);
echo "end";
var_dump($response);
*/
?>

                       

           

2. [代码]python代码   

import urllib2
proxy = '127.0.0.1:8118'
url="http://www.youtube.com"
opener = urllib2.build_opener( urllib2.ProxyHandler({'http':proxy}) )
urllib2.install_opener( opener )
sContent = urllib2.urlopen(url).read()
filepath="a.html"
file1=open(filepath,'wb') 
file1.write(sContent) 
file1.close()

           


           

           

3. [代码]curl脚本     

#使用http代理
curl -x 127.0.0.1:8118 -o m1.mp3 http://realaudio.rferl.org/voa/LERE/manual/2013/05/17/1e86b46f-17b6-4988-9ba2-2c3c635c4d3c.mp3

#使用socks5
curl --socks5 127.0.0.1:8888 -o m.mp3 http://realaudio.rferl.org/voa/LERE/manual/2013/05/17/1e86b46f-17b6-4988-9ba2-2c3c635c4d3c.mp3

           


       

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn