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.

Parsing results

Discussion in 'PHP' started by designervision, May 11, 2007.

  1. #1
    Help! I am trying to get results from google and live search to display their results on a page on my server. If a user searches then the results from both those sites will be displayed - theoretically.
    SEMrush
    Here is my code so far: - i just don't know how to parse results.. please help.

    <?php
    
    $links = array("http://www.google.co.uk/search?q={QUERY}", "http://search.live.com/results.aspx?q={QUERY}");
    
    $query = $_POST['query']; // Contains the value of what you want to search for
    
    foreach($links as $url) {
     $url = str_replace("{QUERY
    
    }", $query, $url);
     $content = file_get_contents($url);
     echo "Results!" . "$content\n\n";
    }
    
    ?>

    Sam.
     
    designervision, May 11, 2007 IP
    SEMrush
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That'll be a waste of time. You will have to regexp your way through the source, which they change regularly to stop scrapers like you. That way you get to rewrite your script every couple of days.

    For Live you can use their RSS feeds instead. Google has a dying API you may want to consider.
     
    T0PS3O, May 11, 2007 IP
  3. designervision

    designervision Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i just want to display googles results - im sure that is possible - what about this site? www.dogpile.com they do it
     
    designervision, May 11, 2007 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    They have an agreement of source with technical backup of such a deal. They certainly aren't scraping the content, wasting all that bandwidth.
     
    T0PS3O, May 11, 2007 IP
  5. designervision

    designervision Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    how can i do it then?
     
    designervision, May 11, 2007 IP
  6. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #6
    TOPS30 gave u the correct answer , use rss for live and The API for google .
     
    commandos, May 11, 2007 IP
  7. designervision

    designervision Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    how can i do this?
     
    designervision, May 11, 2007 IP
  8. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280