CURL, need help with a request using a proxy
There is a site that is loaded only using VPN: https://www.yad2.co.il/
My task is to parse some data. I can and can do this, but the problem is that I can't pull out the htmlkuh. I found a site with a list of proxy servers, tried this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.yad2.co.il/');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_PROXY, '110.232.252.249:8080');
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['User-Agent:Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)']);
And this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.yad2.co.il/');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_PROXY, '110.232.252.249:8080');
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['User-Agent:Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)']);
And many other different combinations, but nothing comes out. Please tell me how to get the content of the site
1
1 answers
Suspicious site. What are you doing there? )))
$url = "https://www.yad2.co.il/";
function get_url($url) {
$proxy_ip = '157.245.124.217:3128';
$ch = curl_init();
if($ch === false)
{
die('Failed to create curl object');
}
$timeout = 25;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip );
//доступные значения для типа используемого прокси-сервера: CURLPROXY_HTTP (по умолчанию), CURLPROXY_SOCKS4, CURLPROXY_SOCKS5, CURLPROXY_SOCKS4A или CURLPROXY_SOCKS5_HOSTNAME.
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['User-Agent:Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)']);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo get_url($url);
1
Author: Denis640Kb, 2020-01-21 23:03:15