欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php代理*

程序员文章站 2022-04-03 12:45:15
...
跳至
 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


相关标签: php代理*