I have a question does anyone know if we can just use like a socket connection or file connection to google, and get like keyword position by searching thru the text? I mean is this allowed? Doesn't it take away resources from google and is slow? I want to design a keyword position checker, but I dunno if google API can be used for that using PHP. (which i have no idea where to begin). I've searched the web for a php code for this check but couldn't find one. I know where to find the tool, but not a php source code for it, so i can learn how its done.
yes it uses google resources and is therefore forbidden by their TOS and can get your IP banned -- trust me , threads about this subject can be found at this forum You CAN use the Google API which gives back different results then the actual www.google.com site , but still usable. Our hero, and for females desired man-to-be, DigitalPoint has created a tool you can use online that you are looking for at http://www.digitalpoint.com/tools/keywords/ `
oh i know that... but i was wondering if there was a way to use the XML and stuff to be able to make my own without going against their ToS, and using PHP rather than the crappy examples API google gave me about JAVA which i dont really know much about.
I use the following code at one of my sites. You can see if it's usable. <?php // $searchquery is the value to search for. // The script replaces the spaces and ampersands and // converts them to values that google is expecting. // $searchurl is the url to find - ie www.web-max.ca // Do not pass http:// - you don't need it. if(!empty($searchquery) && !empty($searchurl)) { $query = str_replace(" ","+",$searchquery); $query = str_replace("%26","&",$query); // How many results to search through. $total_to_search = 1000; // The number of hits per page. $hits_per_page = 100; // Obviously, the total pages / queries we will be doing is // $total_to_search / $hits_per_page // This will be our rank $position = 0; // This is the rank minus the duplicates $real_position = 0; $found = NULL; $lastURL = NULL; for($i=0;$i<$total_to_search && empty($found);$i+=$hits_per_page) { // Open the search page. // We are filling in certain variables - // $query,$hits_per_page and $start. $filename = "http://www.google.com/search?as_q=$query". "&num={$hits_per_page}&hl=en&ie=UTF-8&btnG=Google+Search". "&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=". "&as_qdr=all&as_nlo=&as_nhi=&as_occt=any&as_dt=i". "&as_sitesearch=&safe=images&start=$i"; $file = fopen($filename, "r"); if (!$file) { echo "<p>Unable to open remote file $filename.\n"; } else { // Now load the file into a variable line at a time while (!feof($file)) { $var = fgets($file, 1024); // Try and find the font tag google uses to show the site URL if(eregi("<font color=#008000>(.*)</font><nobr>",$var,$out)) { // If we find it take out any <B> </B> tags - google does // highlight search terms within URLS $out[1] = strtolower(strip_tags($out[1])); // Get the domain name by looking for the first / $x = strpos($out[1],"/"); // and get the URL $url = substr($out[1],0,$x); $position++; // If you want to see the hits, set $trace to something if($trace)print($url."<br>"); // If the last result process is the same as this one, it // is a nest or internal domain result, so don't count it // on $real_position if(strcmp($lastURL,$url)<>0)$real_position++; $lastURL = $url; // Else if the sites match we have found it!!! if(strcmp($searchurl,$url)==0) { $found = $position; // We quit out, we don't need to go any further. break; } } } } fclose($file); } if($found) { $result = "The site $searchurl is at position $found ". "( $real_position ) for the term <b>$searchquery</b>"; } else { $result = "The site $searchurl is not in the top $total_to_search ". "for the term <b>$searchquery</b>"; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="../webmax.css" rel="stylesheet" type="text/css"> </head> <body class="bodytext"> <form> <table width="450" border="0" align="center" cellpadding="0" cellspacing="0" class="bodytext"> <tr> <td width="144"><p>Enter search term:</p></td> <td width="255"><input name="searchquery" type="text" class="bodytext" id="searchquery2" value="<?php print($searchquery);?>"></td> </tr> <tr> <td>Enter URL to search for:</td> <td><input name="searchurl" type="text" class="bodytext" id="searchurl2" value="<?php print($searchurl);?>" size="40"></td> </tr> <tr> <td> </td> <td><input name="Submit" type="submit" class="bodytext" value="Search"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2"><?php print($result);?></td> </tr> </table> </form> </body>
Hmmm you are using file open and close, to get results,and this is what i was sort of thinking of, but i wasn't sure if it is allowed or not. Or is it just socket connections that are restricted? See look: 'You may not send automated queries of any sort to Google's system without express permission in advance from Google. Note that "sending automated queries"' So do i have to get permission? Like webmaster-toolkit.com or something? Or that one website, how do they do it? Do they have permissions also?
Actually I have not thought about it much. I use it privately only, so it does not produce much footprint anyway.
Well won't they IP block you or anything? Do you think if i ask they will give me permission? Also does this include having a google site: search box? However their ToS thing says things that check web page rank! only
Just copy and paste the script on a page on your site and check it. I have run it for months and have not had any problems with it. It checks the first 1000 positions. I don't know how accurate it is though. I use it to get an idea about what positions I'm having. By the way: I didn't make it. I found it on the net somewhere, and just started using it. In the results it shows 2 different numbers. One plain number and one inside parantheses (). I don't know what the last number is, but would like to know if you find out.
Possibly because it cant tell the difference between a query like you said and my a person doing it. So i guess its safe, but i just want to be sure... anyone have any ideas? The script is very plain and simple, it was exactly what i was thinking of, opening the file and reading it for like a specific tag, like color, and thats exactly what it does, should be pretty accurate.
Why not use the API, the script breaks Google's TOS if your tool ever become popular Google will notice and just block you.
thats what im saying... but API i cant use it, because 1st i don't know how, second there is no PHP example for it. Third It uses java and other languages i dont understand. And some stuff called SOAP XML. I need some help on API perhaps, because i don't exactly wanna use my script privately i wanna share with friends etc. I'm sure there is some SOAP PHP things i've heard of but im not quite sure where to begin. Ill do some more research and post back.
Use one of the existing keyword tracking tools, such as Positiono.com This system use many proxy servers.