Results 1 to 4 of 4

Thread: Need to Crop results.

  1. #1
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Need to Crop results.

    Ok here it is I am using this code

    PHP Code:
    <?php 
    $search 
    = array(' ','"');
    $replace = array('+','%22');
    $subject $q;
    $myurl str_replace($search$replace$subject); 
    include 
    'simple_html_dom.php'
    $html file_get_html("http://www.google.com/search?hl=en&q=".$myurl."&aq=f&oq=");
    $v = array(); 
    foreach(
    $html->find('div[class="s"]') as $e) {  
        
    $v[] = substr($e->plaintext0200); 

    $v implode(""$v); 
    ?>
    to get all the decriptions from googles results page and input it into my meta tag.

    So if you searched "Big Dog" on Google my meta tag would display

    <meta name="description" content="Big Dog - Big Dog Motorcycles is the leading producer of custom, American V-twin motorcycles. Five models, each powered by a 117 cubic inch engine, set a new standard ...www.bigdogmotorcycles.com/ - 11k - CacheBigDog is the alpha male of the Boston Dynamics family of robots. ... BigDog is the size of a large dog or small mule, measuring 1 meter long, ...http://www.bostondynamics.com/conten...tion=BigDogBig Dog &middot; Little Dog &middot; Rise &middot; Boston Dynamics - Click to return to home page. products &middot; Robotics &middot; about us &middot; contact. BigDog Sets World Record! ...www.bostoBig Dogs, Quality, value, and fun for the entire family. Since 1983. Big sizes available. Graphic T-Shirts. Show stock quote for&nbsp;WALKwww.bigdogs.com/ - 8k - Cached - Similar pagesFeb 26, 2009 ... If you were freaked out by the spooky Big Dog quadruped robot, you are going to love seeing it in action alongside US Army soldiers, ...gizmodo.com/5160863/big-dogs-us-army-antics-keeUpdate If you were amazed by this don't miss the hilarious spoof It's even better Boston Dynamics keeps working on.gizmodo.com/368651/new-video-of-bigdog-quadruped-robot-is-so-stunning -its-spBasic English grammar designed for beginning students and as a quick review, with interactive online exercises. Un sitio para aprender lo mínimo necesario ...aliscot.com/bigdog/ - 14k - Cached - Similby Big Dog on Mar 18, 2009 at 22:34 Political Leave a comment ..... Big Dogs House is proudly powered by WordPress | Entries (RSS) and Comments (RSS) ...www.onebigdog.net/ - 67k - Cached - Similar pa">

    What I am trying to do now that I have acheive the results I was looking for is crop this text own to say 400 characters.

    Can anyone help?

    Tim..
    Last edited by tgallagher26; 03-19-2009 at 05:30 PM.

  2. #2
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    The substr() function allows you to shorten a string to a set number of characters. For 400, it would be $string = substr($string, 0, 400);

  3. #3
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    I have that in place but the thing is that Googles results page has several <div class="s"> so it is cropping each one instead of the complete results.

    Tim..

  4. #4
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Ok I solved it myself LOL

    Just added

    PHP Code:
    $finalsubstr($v0300); 
    To the end.

    enjoy if ithelps anyone else.

    Tim..

Bookmarks

Posting Permissions

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