Urgent Help On Curl

Discussion in 'PHP' started by baddot, Aug 1, 2009.

  1. #1
    hi everyone i have this problem which i cannot get the right link to download it seems encoded when i use the curl when i click on the website link to go in i can download the file can anyone slove this ? is this something to do with the useragent ? And can i know how do i make it download manually into the serverit self ? from tube8 ?

    please advise thanks in advanced
    
    $userAgent ='# IE 6 - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
    $url = "http://www.tube8.com/hardcore/hot-girl-fucked-by-two-cocks/164977/";
    $ch = curl_init();    // initialize curl handle
    curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
    curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
    //curl_setopt($ch, CURLOPT_POST, 1); // set POST method
    //curl_setopt($ch, CURLOPT_POSTFIELDS, "url=index%3Dbooks&field-keywords=PHP+MYSQL"); // add POST fields
    $result = curl_exec($ch); // run the whole process
    curl_close($ch); 
    echo $result;
    
    PHP:

     
    baddot, Aug 1, 2009 IP
  2. cosminx2003

    cosminx2003 Active Member

    Messages:
    581
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I think you need to download the videos, so you should look for the flv direct links in the source code.
     
    cosminx2003, Aug 1, 2009 IP
  3. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #3
    Better is change the url in your example which is not suited for all age users, and after all you need example.

    Example 1: PHP will do the job

    $result = file_get_contents("http://YOUR_URL_GOES_HERE");
    echo $result;
    Code (markup):
    Example 2:

    
    $result = "";
    
    $f = fsockopen ("http://YOUR_URL_GOES_HERE", 80, $errno, $errstr, 10); #exit after 10 seconds if no response
    if (!$f)  die("$errstr ($errno)");
    else {
        fputs ($f, "GET / HTTP/1.0\r\nHost: YOUR_URL_GOES_HERE\r\n\r\n");
        while (!feof($fp))  $result .= fgets ($f,1024);
        fclose ($f);
    }
    
    echo $result;
    
    Code (markup):
    regards
     
    Vooler, Aug 2, 2009 IP