ok, here is what i came up with. it probably sucks from a coding standpoint, but it does what i need it to do, which is what matters. you have to input the keywords as comma separated in one big chunk, i couldn't figure out how to input them as a list. i take a keyword list and change it to comma separated using ms word, before putting it into the form.
later i would like to cut out this step, by just putting in the list with paragraph returns in the box. i tried putting the list in but only the first keyword gets recognized by the form.
i have a random delay in there (sleep function) to ward off big G from getting mad at me. not sure if i need it, but i put it in there as a precaution. take it out and let me know what happens. obviously as it is this takes about 15 minutes to run for a 90 word list. which is a minor inconvenience.
the core of this is from Smaxtor, so thanks sir for your tutorials.
also there are two parts, the form and then the form handler, the form handler does all the work. this is the form (put in your own html headers and crap):
Code:
<form action="handle_form.php" method="post">
<fieldset><legend>Enter your comma separated (no spaces) keyword list in the box below:</legend>
<p><b>Keyword list:</b>
<input type="text" name="keyword" style="height: 100px;" rows="5" cols="60" wrap="on" /></p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit the Keywords" /></div>
</form>
here is the second part, which you would name "handle_form.php"
Code:
<?php
$keyword = $_REQUEST['keyword'];
$keywordarray = explode (',',$keyword);
foreach ($keywordarray as $value) {
$sleep = rand(9, 13);
sleep($sleep);
$keyfix = str_replace(" ", "+", $value);
$url = "http://www.google.com/search?q=allintitle%3A" . $keyfix . "&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
$data = $curl_scraped_page;
$about = '/of about/';
$nomatch = '/did not match/';
if (preg_match($about, $data)) {
$regex = '/of about (.+?) for/';
preg_match($regex,$data,$match);
$result = $match[1];
}
elseif (preg_match($nomatch, $data)) {
$result = '<b>0</b>';
}
else {
$regex = '/Results (.+?) - (.+?) of (.+?) for/';
preg_match($regex,$data,$match);
$result = $match[3];
}
echo "$value, ";
echo "$result<br />";
}
?>
as i said this works well, i used it on a list of about 90 keywords a couple of times.
the hard part was that you have to handle 3 different types of search results, sometimes G says "about" so many pages and sometimes it just says the number of pages without "about." and of course sometimes there is no result so you have to account for that and have the script spit out "0"
i have no idea how to run this thru proxies, maybe i will try to do that later if i find the need to do so.
any suggestions please let me know.
as i said, it probably isn't great, but i'm extremely proud of it hehe
if anyone is wondering what this is for, i'm working on a site that i want to get organic searches, so i'm going to write pages around certain keywords that are searched alot but have less competition.
i already know the search numbers for the words, but i want to find out which keywords have few pages with that keyword in the title. doing pages with those keywords as the title should help SEO. at least that's my theory.