Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't seem to get a web page's contents via cURL - user agent and HTTP headers both set?
    primarykey
    data
    text
    <p>For some reason I can't seem to get this particular web page's contents via cURL. I've managed to use cURL to get to the "top level page" contents fine, but the same self-built quick cURL function doesn't seem to work for one of the linked off sub web pages.</p> <p><strong>Top level page:</strong> <code>http://www.deindeal.ch/</code></p> <p><strong>A sub page:</strong> <code>http://www.deindeal.ch/deals/hotel-cristal-in-nuernberg-30/</code></p> <p><strong>My cURL function (in functions.php)</strong></p> <pre><code>function curl_get($url) { $ch = curl_init(); $header = array( 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'Accept-Language: en-us;q=0.8,en;q=0.6' ); $options = array( CURLOPT_URL =&gt; $url, CURLOPT_HEADER =&gt; 0, CURLOPT_RETURNTRANSFER =&gt; 1, CURLOPT_USERAGENT =&gt; 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13', CURLOPT_HTTPHEADER =&gt; $header ); curl_setopt_array($ch, $options); $return = curl_exec($ch); curl_close($ch); return $return; } </code></pre> <p><strong>PHP file to get the contents (using echo for testing)</strong></p> <pre><code>require "functions.php"; require "phpQuery.php"; echo curl_get('http://www.deindeal.ch/deals/hotel-walliserhof-zermatt-2-naechte-30/'); </code></pre> <p><strong><em>So far I've attempted the following to get this to work</em></strong></p> <ul> <li>Ran the file both locally (XAMPP) and remotely (LAMP).</li> <li>Added in the user-agent and HTTP headers as recommended here <a href="https://stackoverflow.com/questions/4597309/file-get-contents-and-curl-cant-open-a-specific-website">file_get_contents and CURL can&#39;t open a specific website</a> - before the function <code>curl_get()</code> contained all the options as current, except for CURLOPT_USERAGENT<code>and</code>CURLOPT_HTTPHEADERS`.</li> </ul> <p>Is it possible for a website to completely block requests via cURL or other remote file opening mechanisms, regardless of how much data is supplied to attempt to make a real browser request?</p> <p>Also, is it possible to diagnose why my requests are turning up with nothing?</p> <p>Any help answering the above two questions, or editing/making suggestions to get the file's contents, even if through a method different than cURL would be greatly appreciated ;).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload