Home > php教程 > PHP源码 > body text

php代理fanqiang

PHP中文网
Release: 2016-05-25 17:05:20
Original
3199 people have browsed it

跳至

 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);
*/
?>
Copy after login

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()
Copy after login


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
Copy after login

           


       

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!