1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to get meta tags from web page - title, description, keywords

Discussion in 'PHP' started by crodex, Jun 21, 2011.

  1. #1
    I'd Like to get meta tags automaticly for web sites registered on my site.
    I am using this function
    http://php.net/manual/en/function.get-meta-tags.php
    but it is not working 100%

    Can someone suggest other solution/method
    SEMrush
    Thank you
     
    crodex, Jun 21, 2011 IP
    SEMrush
  2. SiJz

    SiJz Peon

    Messages:
    51
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The best way would be to fetch the page and parse out the info you want.
    That way, you could extract title, meta's, favicon etc.

    It's really quite simple - fetch the page (could use curl if you wanted also), a few string functions to chop up the grabbed data and that's it.

    If I get a chance tomorrow, I'll knock up and test a little script to do this.

    Si
     
    SiJz, Jun 21, 2011 IP
  3. dj_sonu2003

    dj_sonu2003 Well-Known Member

    Messages:
    108
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    you can also fatch the Meta from your database Its quit simple!!!
     
    dj_sonu2003, Jun 22, 2011 IP
  4. crodex

    crodex Greenhorn

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    SiJz, parsing is one option. Before that I am looking some script and function.

    Dj, we don't have that in our DB. In our form we ask for a web link and in next step we would like to get meta tags automaticly for that site.

    I know that many directories when you submit your link pull meta tags from your site. That is what we want to do.
     
    crodex, Jun 22, 2011 IP
  5. niks00789

    niks00789 Well-Known Member

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #5
    using simple_html_dom parser...
    its just a single php file you need to include in your php file..
    use curl or file_get_contents to grab the page from which you need to extract meta tags, say in $page_source
    then assign it to a variable say, $html by using $html = str_get_html($page_source)

    Then u can easily find meta tags using something like

    echo $html->find('meta[name="description"] , 0')->value;

    echo $html->find('meta[name="keywords"] , 0')->value;

    Havent tested it, but it should mostly work...
     
    niks00789, Jun 22, 2011 IP
  6. sudhisinha

    sudhisinha Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i have no accurate idea....
     
    sudhisinha, Jun 22, 2011 IP
  7. AdsMakeSense

    AdsMakeSense Active Member

    Messages:
    389
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    70
    #7
    You use cURL to fetch the html contents then, you read from the fetched contents.
     
    AdsMakeSense, Jun 22, 2011 IP
  8. mindblaster

    mindblaster Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    fetch the data by using curl library and store in database
     
    mindblaster, Jun 28, 2011 IP