Check Google for URL using PHP?

Discussion in 'PHP' started by freestate, Jan 2, 2008.

  1. #1
    Hey,

    I have a site that needs to check whether URLs submitted by users are listed in Google.

    My question to you fine folk is, how can I achieve this using PHP, preferably as simply as possible?

    i.e.

    User submits URL through form
    Script runs a query against Google to check that URL exists in Google's listings and then returns true or false.

    I'm basically looking to identify whether URLs submitted are banned from Google's index.

    Thanks in Advance! :)
     
    freestate, Jan 2, 2008 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You will need to use file_get_contents or curl to download the searcch page from google, then use regular expressions to parse the page.
     
    matthewrobertbell, Jan 2, 2008 IP
  3. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #3
    Better to do with AJAX to avoid browser time outs, because searches can be over hundreds of pages.
     
    Kaizoku, Jan 2, 2008 IP
  4. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The first page of the search will show wether that page is indexed or not.
     
    matthewrobertbell, Jan 2, 2008 IP
  5. freestate

    freestate Well-Known Member

    Messages:
    975
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Thanks for the help guys...

    Checking Google, I guess the easiest way of doing it is to search for the "did not match any documents" string after querying site:www.domain.com

    Cheers!
     
    freestate, Jan 3, 2008 IP
  6. mantram

    mantram Banned

    Messages:
    171
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Please make sure that you sign up for google API if you have a lot of queries or else u will get banned.
     
    mantram, Jan 3, 2008 IP
  7. marshall_26

    marshall_26 Peon

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'd use curl :)
     
    marshall_26, Jan 3, 2008 IP
  8. freestate

    freestate Well-Known Member

    Messages:
    975
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    160
    #8
    Thanks all - I'll experiment with curl (complete with API ;) ) and see how I get on!
     
    freestate, Jan 4, 2008 IP
  9. JamesFarrell

    JamesFarrell Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    HI, I'm doing the same thing today.

    I found this spider tutorial

    I am a little concerned with getting banned though as I'm dabbling a little above my head here.

    I am spidering a google search result:
    http://www.google.ie/search?hl=en&q=http%3A%2F%2Fwww.example.com%2F&btnG=Google+Search&meta=
    HTML:
    I have included the
    <script src="http://www.google.com/jsapi?key=
    HTML:
    with my google API key, because someone above mentioned it.

    Will this be enough to prevent me being banned or do I have to some how use the google API to interface to do my queries.
     
    JamesFarrell, Jan 4, 2008 IP