Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default [HELP] Getting info off an external page and putting it onto my own.

    Hiii,

    I am looking for help with trying to get hold of a bit of source code on a web page. For examples sake, let's say it's YouTube, and I want to get the video description.

    For example. Let's say the URL is http://youtube.com/watch?v=p0DWvta7pg0
    and I want to get this code off the page and onto mine:

    PHP Code:
                  <span id="vidDescBegin"
    This is like the video description.
    </
    span
    I want to do this as my site has a few of my favourite YouTube videos on it and I would like for the video descriptions to come up below the videos.

    I'm not sure if you'd do
    PHP Code:
    <?php
    file_get_contents
    ("http://youtube.com/watch?v=p0DWvta7pg0",<span id="vidDescBegin>,</span>");
     
    ?>
    or something like that, any help appreciated greatly. will rep if i can.

    Moved by opensourcehost (Forum Moderator) from Web Designing: Please post in the correct forum next time, thanks .
    Last edited by Mr.OSH; 15-07-2007 at 08:46 PM.
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    3,285
    Tokens
    0

    Latest Awards:

    Default

    The easiest way is to use a little function that it easily available on the Internet called "get_string_between". Here is how you'd do it:

    PHP Code:
    <?php
    /* String function */
    function get_string_between($string$start$end){
            
    $string " ".$string;
            
    $ini strpos($string,$start);
            if (
    $ini == 0) return "";
            
    $ini += strlen($start);  
            
    $len strpos($string,$end,$ini) - $ini;
            return 
    substr($string,$ini,$len);

    /* End string function */

    $yt file_get_contents("URL OF YOUTUBE PAGE");
    $spancontents get_string_between($yt"<span id='whatever-it-is'>""</span>");
    ?>



    i used to be NintendoNews. visit my blog or add me on twitter.
    need help with vista? i am a microsoft certified technology specialist in configuring windows vista and connected home integrator.. pm me for help!


    "I am the way, the truth, and the life. No one comes to the Father except through me"
    John 14:6 (NIV)


  3. #3
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Easier code

    PHP Code:
    $tehsource file_get_contents("www.youtube.com etc");
    $step1 explode('<span id="vidDescBegin">'$tehsource);
    $step2 explode('</span>'$step1[1]);
    $youtubedescription $step2[0]; 

  4. #4
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Genral purpous gabbing code i wrote a while back

    PHP Code:
    //Genral Purpos content Grabbing Function.    
    //By Carl (http://thybag.co.uk)
    function GrabContent($url,$prefix,$suffix){
            
    // get page contents
            
    $page file_get_contents($url);
            
    //search for matches
            
    preg_match_all("#".$prefix."(.+?)".$suffix."#is"$page$finds);
            
    // [0] matches + param  - [1] matches
            
    return $finds[1];
    }
    //test it on habbox

    $foundarray GrabContent("https://habbox.com/site/","<div class='section' ><div class='shadow' ><div class='menuBox' >",'</div></div></div>');

    print_r ($foundarray); 
    It returns a multi level array of everything maching the search paramiters, so if theres a repeteing part u can grab each one of them seperatly

  5. #5
    Join Date
    Jun 2007
    Location
    Look behind you.
    Posts
    1,289
    Tokens
    0

    Latest Awards:

    Default

    <object width="425" height="350"><param name="movie" value="<A href="http://www.youtube.com/v/p0DWvta7pg0"></param><param">http://www.youtube.com/v/p0DWvta7pg0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/p0DWvta7pg0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

    If it's just basic html, but I see your wanting PHP.

  6. #6
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Err no. He does not want to play the video on his site.

    Quote Originally Posted by Criminal View Post
    <object width="425" height="350"><param name="movie" value="<A href="http://www.youtube.com/v/p0DWvta7pg0"></param><param">http://www.youtube.com/v/p0DWvta7pg0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/p0DWvta7pg0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

    If it's just basic html, but I see your wanting PHP.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •