我正在尝试使用https://proxy6.net上的袜子代理,我在那里获得IP,端口以及诸如用户名和密码之类的数据。 问题出在php上,我使用了How to use CURL via a proxy?中的代码,并设置了我的帐户和代理。像这样:
$proxy = 'ip:port';
$proxyauth = 'user:pass';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // URL for CURL call
curl_setopt($ch, CURLOPT_PROXY, $proxy); // PROXY details with port
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth); // Use if proxy have username and password
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); // If expected to call with specific PROXY type
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // If url has redirects then go to the final redirected URL.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Do not outputting it out directly on screen.
curl_setopt($ch, CURLOPT_HEADER, 1); // If you want Header information of response else make 0
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
echo $curl_scraped_page;
,但是代码不显示任何内容。即使当我尝试正常卷曲(不使用代理)时,它也会显示我的ip。
我在计算机上使用PHP 7.3.9。代码有问题吗?