Home  >  Article  >  Backend Development  >  PHP uses curl to implement the method of obtaining data through a proxy

PHP uses curl to implement the method of obtaining data through a proxy

墨辰丷
墨辰丷Original
2018-06-02 11:08:578079browse

This article mainly introduces the implementation method of using curl to obtain data through proxy in php. It mainly involves the usage skills of CURLOPT_PROXYUSERPWD parameter in php curl. Friends in need can refer to it

The details are as follows:

$curl=curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.baidu.com/");
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0');
curl_setopt($curl, CURLOPT_REFERER, 'http://www.guahao.com/');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($param));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true);
curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($curl, CURLOPT_PROXY, "180.186.11.121");
curl_setopt($curl, CURLOPT_PROXYPORT, "37211");
curl_setopt($curl, CURLOPT_PROXYUSERPWD, "taras:taras-ss5");
$result=curl_exec($curl);

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

PHP implements multi-image upload and single-image upload functions

PHP mobile phone SMS verification code implementation process Detailed explanation

phpWeChat public platform development WeChat group messaging example sharing

The above is the detailed content of PHP uses curl to implement the method of obtaining data through a proxy. For more information, please follow other related articles on the PHP Chinese website!

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