www.webdeveloper.com
Results 1 to 15 of 16

Thread: Get website metea tags with Ajax, PHP and Jquery

Threaded View

  1. #1
    Join Date
    Dec 2009
    Posts
    92

    Get website metea tags with Ajax, PHP and Jquery

    Hi,
    I have a script which allows to fetch website content as plain HTML. It is written in PHP like this:

    Code:
    <?php
    if(isset($_GET['site'])){
      $f = fopen($_GET['site'], 'r');
      $html = '';
      while (!feof($f)) {
        $html .= fread($f, 24000);
      }
      fclose($f);
      echo $html;
    }
    ?>
    With a bit of Jquery/Ajax I can 'find' links in the data and show them as plain HTML like this:

    Code:
    $(function(){
    
       var site = 'http://www.SomeSite.com/';
    
       $.get('proxy.php', { site:site }, function(data){
    
            headlines = $(data).find('a');
    
            headlines.map(function(elem, index){ 
    
                href = $(this).prop('href');
    
                $('#Div').append('' + href + '');
    			
            });
    
       }, 'html');

    Instead of getting the 'url' I would really like to fetch the meta data (description, title etc.). So I tried:

    Code:
    ....
    headlines = $(data).find('meta');
    
    headlines.map(function(elem, index){ 
          
    meta = $(this).attr('meta[name='title'');
    
                $('#Div').append('' + meta + '');
    			
            });
    I tried many other variations but I can't seem to get it to work. Help is very much appreciated.
    Last edited by yomoore; 12-28-2012 at 12:52 PM. Reason: updated code

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles