I am trying to fetch the contents of a url but file_get_contents is returning "File not found". This is the code I am using:
$url = "https://www.auction.com/residential/CA/active_lt/land_pt/resi_sort_v2_st/y_nbs/";
$context = stream_context_create(array(
'https' => array(
'method' => "GET",
'header' =>
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" .
"Accept-Language: en-US,en;q=0.8\r\n".
"Keep-Alive: timeout=3, max=10\r\n",
"Connection: keep-alive",
'user_agent' => "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.66 Safari/535.11",
"ignore_errors" => true,
"timeout" => 3
)
));
file_get_contents($url, false, $context);
But it is not working. Can you please help make this work? Or, is there any other method?
Try this its work at my end
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => "https://www.auction.com/residential/CA/active_lt/land_pt/resi_sort_v2_st/y_nbs/",
//CURLOPT_HTTPHEADER => array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n','Accept-Language: en-US,en;q=0.8\r\n','Keep-Alive: timeout=3, max=10\r\n','Connection: keep-alive'),
CURLOPT_POST => false,
CURLOPT_RETURNTRANSFER => true,
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
echo'<pre>';print_r($result);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.