Help with get_data

Discussion in 'PHP' started by DjZoC, May 14, 2010.

  1. #1
    hello there, im tryng to get_data of pornhub.com videos page

    video url: http://www.pornhub.com/view_video.php?viewkey=2090183744

    i try this code but is not working


    <?php

    $url = 'http://www.pornhub.com/view_video.php?viewkey=2090183744';
    $url_page = get_data($url);

    echo $url_page;

    ?>


    can someone help me how i can make this script to work ? thanks
     
    DjZoC, May 14, 2010 IP
  2. swashata

    swashata Member

    Messages:
    86
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Whats inside the function get_data? It is not a predefined function! It seems that you have to use cURL to make what you want!
     
    swashata, May 15, 2010 IP
  3. dhvanit

    dhvanit Peon

    Messages:
    137
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try with file_get_contents :

    <?php
    $data = file_get_contents('http://www.pornhub.com/view_video.php?viewkey=2090183744');
    echo $data ;
    ?>
     
    dhvanit, May 15, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Use curl my friend

    
    <?php
    
    $url = 'http://www.pornhub.com/view_video.php?viewkey=2090183744';
    
    	$ch = curl_init();
    	curl_setopt($ch, CURLOPT_USERAGENT, 'Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6');
    	curl_setopt($ch, CURLOPT_URL,$url);
    	curl_setopt($ch, CURLOPT_FAILONERROR, true);
    	curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    	$html= curl_exec($ch);
    	if (!$html) {
    		echo "<p>cURL error:" . curl_error($ch) . " (Number " . curl_errno($ch).")</p>";
    	}
    	curl_close($ch); 
    
    ?>
    
    PHP:
     
    roopajyothi, May 15, 2010 IP
  5. swashata

    swashata Member

    Messages:
    86
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #5
    roopajyothi just gives you the solution :)
     
    swashata, May 15, 2010 IP
  6. DjZoC

    DjZoC Member

    Messages:
    167
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    work thank you !

    one more question, i try to add this command but is not working :(

    <?php
    
     $url = 'http://www.pornhub.com/view_video.php?viewkey=676a0528f8dd15588f85';
    
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_USERAGENT, 'Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6');
     curl_setopt($ch, CURLOPT_URL,$url);
     curl_setopt($ch, CURLOPT_FAILONERROR, true);
     curl_setopt($ch, CURLOPT_AUTOREFERER, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     $html= curl_exec($ch);
     if (!$html) {
      echo "<br />cURL error number:" .curl_errno($ch);
      echo "<br />cURL error:" . curl_error($ch);
      exit;
     }
    
     $live_sex_m = get_match('/<li>(.*)Live Sex<\/a><\/li>/',$html);
     $html = str_replace('<li>' . $live_sex_m . 'Live Sex</a></li>', '', $html);
    
    
     echo $html;
    
    ?>
    PHP:
    can someone tell me what is the problem, thanks
     
    Last edited: May 15, 2010
    DjZoC, May 15, 2010 IP
  7. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #7
    whats this get_match()??

    try replacing:

     $live_sex_m = get_match('/<li>(.*)Live Sex<\/a><\/li>/',$html);
    $html = str_replace('<li>' . $live_sex_m . 'Live Sex</a></li>', '', $html);
    PHP:
    with:

    preg_match('/<li>(.*)Live Sex<\/a><\/li>/', $html, $live_sex_m);
    $html = str_replace('<li>' . $live_sex_m[1] . 'Live Sex</a></li>', '', $html);
    PHP:
    Also read up on user defined functions and their usage: http://php.net/manual/en/functions.user-defined.php
     
    danx10, May 16, 2010 IP
  8. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #8
    Hey where is the function get_match declared first!
    Else try what danx10 said!
     
    roopajyothi, May 16, 2010 IP
  9. DjZoC

    DjZoC Member

    Messages:
    167
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #9
    thanks works ! now i can start to continue my work :) thanks again
     
    DjZoC, May 16, 2010 IP
  10. DjZoC

    DjZoC Member

    Messages:
    167
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #10
    need help again, i make this code for the script but is show me error page "The document has moved here."

    command

     $ph_page = $_REQUEST['page'];
     $uri = $_SERVER['REQUEST_URI'];
     $uri = str_replace('pornhub/?page=videos&', 'video?', $uri);
    
    
     if ($ph_page != "") {
    
      if ($ph_page == "videos") {
       $url = 'http://www.pornhub.com' . $uri;
      }
    
      } else { 
      $url = 'http://www.pornhub.com/';
     }
    PHP:
    can someone help me with this ? thanks !
     
    DjZoC, May 16, 2010 IP
  11. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #11
    I hope the problem is with P**n hub or else it would sen a invalid url to fetch
     
    roopajyothi, May 17, 2010 IP
  12. DjZoC

    DjZoC Member

    Messages:
    167
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #12
    DjZoC, May 17, 2010 IP
  13. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #13
    roopajyothi, May 17, 2010 IP
  14. Jim W. Slagone

    Jim W. Slagone Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Why is everybody set on Pornhub?? Ok, it's one of the most well known Adult Tube sites out there but isn't something like www.whoreslag.com better? I mean they got better content and all. I don't know but it seems that pornhub became a sell out!
     
    Jim W. Slagone, Aug 15, 2011 IP
  15. Cucumba123

    Cucumba123 Well-Known Member

    Messages:
    1,403
    Likes Received:
    34
    Best Answers:
    3
    Trophy Points:
    150
    #15
    What are we discussing here? PHP or porn sites? :rolleyes:
     
    Cucumba123, Aug 17, 2011 IP
  16. Vietto

    Vietto Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
     $url = 'http://www.pornhub.com/view_video.php?viewkey=2090183744';$page_html = file_get_contents ($furl);$echo $page_html; 
    Code (markup):
     
    Vietto, Aug 17, 2011 IP