Home  >  Article  >  php教程  >  PHP CURL使用代理来访问目标

PHP CURL使用代理来访问目标

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

有些时候对方你不能直接使用自己的服务器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);
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