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

PHP CURL使用代理来访问目标

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

有些时候对方你不能直接使用自己的服务器IP来执行CURL,所以找一些很多代理来搞定。你懂的

	$curl=curl_init();
	curl_setopt($curl,CURLOPT_URL, "http://www.fuck.com/login");
	curl_setopt($curl,CURLOPT_HEADER,1);
	curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($curl,CURLOPT_POST,1);
	curl_setopt($curl,CURLOPT_PROXYTYPE,CURLPROXY_SOCKS5);//使用了SOCKS5代理
	curl_setopt($curl, CURLOPT_PROXY, "fuck.3322.org:1080");	
	$data = array('user' => "geek", 'password' => 'fuck');
	curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
	//curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1);如果是HTTP代理
	//curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');cookie你懂的
	$request = curl_exec($curl);
	//var_dump($request);
	curl_close($curl);
Copy after login
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!