Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7002107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:53:13+00:00 2026-05-27T20:53:13+00:00

For some reason I can’t seem to get this particular web page’s contents via

  • 0

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.

Top level page: http://www.deindeal.ch/

A sub page: http://www.deindeal.ch/deals/hotel-cristal-in-nuernberg-30/

My cURL function (in functions.php)

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 => $url, 
        CURLOPT_HEADER => 0, 
        CURLOPT_RETURNTRANSFER => 1, 
        CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13',
        CURLOPT_HTTPHEADER => $header
        );
    curl_setopt_array($ch, $options);
    $return = curl_exec($ch);
    curl_close($ch);

    return $return;
}

PHP file to get the contents (using echo for testing)

require "functions.php";
require "phpQuery.php";

echo curl_get('http://www.deindeal.ch/deals/hotel-walliserhof-zermatt-2-naechte-30/');

So far I’ve attempted the following to get this to work

  • Ran the file both locally (XAMPP) and remotely (LAMP).
  • Added in the user-agent and HTTP headers as recommended here file_get_contents and CURL can't open a specific website – before the function curl_get() contained all the options as current, except for CURLOPT_USERAGENTandCURLOPT_HTTPHEADERS`.

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?

Also, is it possible to diagnose why my requests are turning up with nothing?

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 ;).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:53:14+00:00Added an answer on May 27, 2026 at 8:53 pm

    Try adding:

    CURLOPT_FOLLOWLOCATION => TRUE
    

    to your options.

    If you run a simple curl request from the command line (including a -i to see the response headers) then it is pretty easy to see:

    $ curl -i 'http://www.deindeal.ch/deals/hotel-cristal-in-nuernberg-30/'
    HTTP/1.1 302 FOUND
    Date: Fri, 30 Dec 2011 02:42:54 GMT
    Server: Apache/2.2.16 (Debian)
    Vary: Accept-Language,Cookie,Accept-Encoding
    Content-Language: de
    Set-Cookie: csrftoken=d127d2de73fb3bd72e8986daeca86711; Domain=www.deindeal.ch; Max-Age=31449600; Path=/
    Set-Cookie: generic_cookie=1; Path=/
    Set-Cookie: sessionid=987b1a11224ecd0e009175470cf7317b; expires=Fri, 27-Jan-2012 02:42:54 GMT; Max-Age=2419200; Path=/
    Location: http://www.deindeal.ch/welcome/?deal_slug=hotel-cristal-in-nuernberg-30
    Content-Length: 0
    Connection: close
    Content-Type: text/html; charset=utf-8
    

    As you can see, it returns a 302 with a Location header. If you hit that location directly, you will get the content you are looking for.

    And to answer your two questions:

    1. No, it is not possile to block requests from something like curl. If the consumer can talk HTTP then it can get to anything the browser can get to.
    2. Diagnosing with an HTTP proxy could have been helpful for you. Wireshark, fiddler, charles, et al. should help you out in the future. Or, do like I did and make a request from the command line.

    EDIT
    Ah, I see what you are talking about now. So, when you go to that link for the first time you are redirected and a cookie (or cookies) is set. Once you have those cookie, your request goes through as intended.

    So, you need to use a cookiejar, like in this example: http://icfun.blogspot.com/2009/04/php-how-to-use-cookie-jar-with-curl.html

    So, you will need to make an initial request, save the cookies, and make your subsequent requests including the cookies after that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason i can't seem to get this right ok i have 2
For some reason I can't get this to work. It pulls the name and
For some reason I can't get this script to run when I add the
For some reason I can't seem to get the basic example to work, provided
For some reason I can't get this to work at all. I have read
For some reason I can't get Nexus to serve my SNAPSHOT artifacts via the
For some reason I can't get this batch file to run in my .NET
This question is pretty simple I for some reason can't get the proper result
For some reason I can get this to work, using single proxy everything seems
For some reason I can't seem to use non-capturing groups in MySQL. Is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.