php - How to retrieve the data from a URL with an exclamation mark inside it? -
i retrieve content of website website build exclamation mark in url , doesn't seem work.
things tried:
<?php echo file_get_contents('https://domain.com/path/!weird.formatted?url=1'); echo file_get_contents('https://domain.com/path/%21weird.formatted?url=1'); echo file_get_contents(urlencode('https://domain.com/path/!weird.formatted?url=1')); echo file_get_contents(rawurlencode('https://domain.com/path/!weird.formatted?url=1')); i tried retrieve content php curl here seems exclamation mark problem.
so how retrieve webpage? suggestions highly appreciate.
update
the url try retrieve content from: https://loket.bunnik.nl/mozard/!suite86.scherm0325?mpag=1070
so problem web page checking valid user agent/cookie. code used fix issue:
<?php echo getpage("https://loket.bunnik.nl/mozard/!suite86.scherm0325?mpag=1070"); function getpage ($url) { $useragent = 'mozilla/5.0 (macintosh; intel mac os x 10_8_2) applewebkit/537.36 (khtml, gecko) chrome/44.0.2403.89 safari/537.36'; $timeout= 120; $dir = dirname(__file__); $cookie_file = $dir . '/cookies/' . md5($_server['remote_addr']) . '.txt'; $ch = curl_init($url); curl_setopt($ch, curlopt_failonerror, true); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_cookiefile, $cookie_file); curl_setopt($ch, curlopt_cookiejar, $cookie_file); curl_setopt($ch, curlopt_followlocation, true ); curl_setopt($ch, curlopt_encoding, "" ); curl_setopt($ch, curlopt_returntransfer, true ); curl_setopt($ch, curlopt_autoreferer, true ); curl_setopt($ch, curlopt_connecttimeout, $timeout ); curl_setopt($ch, curlopt_timeout, $timeout ); curl_setopt($ch, curlopt_maxredirs, 10 ); curl_setopt($ch, curlopt_useragent, $useragent); curl_setopt($ch, curlopt_referer, 'http://www.google.com/'); $content = curl_exec($ch); if(curl_errno($ch)) { echo 'error:' . curl_error($ch); } else { return $content; } curl_close($ch); } ?>
Comments
Post a Comment