Home  >  Article  >  php教程  >  php代理fanqiang

php代理fanqiang

PHP中文网
PHP中文网Original
2016-05-25 17:05:203241browse

跳至

 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

           


       

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn