View Full Version : Check Google for URL using PHP?
freestate
Jan 2nd 2008, 8:50 am
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! :)
matthewrobertbell
Jan 2nd 2008, 1:55 pm
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.
Kaizoku
Jan 2nd 2008, 4:49 pm
Better to do with AJAX to avoid browser time outs, because searches can be over hundreds of pages.
matthewrobertbell
Jan 2nd 2008, 5:31 pm
The first page of the search will show wether that page is indexed or not.
freestate
Jan 3rd 2008, 6:11 am
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!
mantram
Jan 3rd 2008, 7:44 am
Please make sure that you sign up for google API if you have a lot of queries or else u will get banned.
marshall_26
Jan 3rd 2008, 11:11 pm
I'd use curl :)
freestate
Jan 4th 2008, 3:29 am
Thanks all - I'll experiment with curl (complete with API ;) ) and see how I get on!
JamesFarrell
Jan 4th 2008, 5:08 pm
HI, I'm doing the same thing today.
I found this spider tutorial (http://spyderwebtech.wordpress.com/2007/12/05/building-a-web-spider-part-2/)
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=
I have included the
<script src="http://www.google.com/jsapi?key=
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.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.