reading url like facebook

Discussion in 'PHP' started by dado_eyad, Dec 23, 2009.

  1. #1
    does any one have an idea about how Facebook read URL and
    extract title and a text from the page.
    I got the title but the text?
     
    dado_eyad, Dec 23, 2009 IP
  2. dado_eyad

    dado_eyad Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    when you give URL to facebook it returns the title of the page, a small text ,and the images from that page.
    I want to know how this work or if there is any script I can use to do that.
    take in mind that the text from the page is the problem.
     
    dado_eyad, Dec 23, 2009 IP
  3. qasimbilal

    qasimbilal Member

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    36
    #3
    $url="http://www.studiesinn.com/";
    $lines = file($url);
    $pageSource='';
    foreach ($lines as $line_num => $line) {
    $pageSource.=$line;
    }

    $title_str=explode('<title>',$pageSource);
    $title_str2=explode('</title>',$title_str[1]);

    //This is your Page Title:
    $page_title=$title_str2[0];

    $desc_str=explode('<meta name="Description" content="',$pageSource);
    $desc_str2=explode('" />',$desc_str[1]);

    //This is your page meta description
    $page_desc=$desc_str2[0];

    Take a look on this and refine this code.
     
    qasimbilal, Dec 23, 2009 IP
  4. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #4
    wow ... thanks for this code ... :)

    yes, url structure fb so strange :p
     
    ghprod, Dec 23, 2009 IP
  5. dado_eyad

    dado_eyad Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks
    i used this http://simplehtmldom.sourceforge.net/
    but facebook doesn't get the text from
    <meta name="Description"
    it reads the page and give you the text from it.
     
    dado_eyad, Dec 23, 2009 IP