Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    592
    Thanks
    0
    Thanked 1 Time in 1 Post

    graping meta description like a searchbot

    Hi

    I'm finding a difficulty in graping meta description like a searchbot because of
    its flexible patterns.

    <meta content="This is my web site description" name="description" />
    <meta name="description" content="This is my web site description" />

    I've tried with the following patterns but in vain :
    Code:
    preg_match('@(?:<meta content="|<meta name="description" content="|<meta content=|<meta name=description content=)+(.*\w+)@i',
    
    preg_match('@(?:<meta content="|<meta name="description" content="|<meta content=|<meta name=description content=)+([^"|/>|>]+)@i',
    
    preg_match('@(<meta content="|<meta content="|<meta name="description" content="|<meta content=|<meta name=description content=)+(.*)([^"]).(name="description" />|name=description>|>|>|/>|"/>|)@i',
    I'd like to get the

    This is my web site description.

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Something to fool with/another idea
    PHP Code:
          while(true)
          {
           
    $begPos strpos($contents,"<meta");
           if (
    $begPos===false) break;.
           
    $endPos strpos($contents,">",$begPos+strlen("<meta"));

               
    //search for your name and contents here within the tag...

           
    if ($loopcontrol++>100) break; //loop infinity control
           
    continue;  //search again
          

    Last edited by iLLin; 03-25-2007 at 07:02 PM.

  • #3
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    $description strpos($contents"description=\"");
    //then end it
    //I would also search for the dink (') too.  Maybe setup an array of possible values?
    //Not sure but I think they HAVE to wrap the description in quotes? 


  •  

    Posting Permissions

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