I figured i'd share, il keep the thread updated as i work on it <?php class ErrorManager //ErrorManager.inc //author: nick from www.blakhatt.com { var $errorFilePointer; var $errorFileName = "error_log.txt"; function ErrorManager() { $errorFilePointer = fopen($this->errorFileName,"a+"); if (!is_resource($this->errorFilePointer)) { echo "Could not create error log file, try creating \"".$this->errorFileName."\" and setting the appropriate permissions."; exit; } } function addError($errorString) { fwrite($this->errorFilePointer,$errorString); } function getLastError() { if (is_readable($this->errorFileName)) { $errorData = file_get_contents($this->errorFileName); $errorArray = explode("\n",$errorData); return $errorArray[count($errorArray)]; } else { return 0; } } function printErrors() { if (is_readable($this->errorFileName)) { $errorData = file_get_contents($this->errorFileName); $errorArray = explode("\n",$errorData); foreach ($errorArray as $error) { echo "ERROR:".$error."<br>"; } } else { return 0; } } } ?> Code (markup): <?php //KeywordManager.inc include "ErrorManager.inc"; class KeywordManager { //class variables var $keywordArray = array(); function KeywordManager() { //init function $errorManager = new ErrorManager(); //create error manager object } function saveKeywordFile($fileName) { /* saves file with specified array of keywords and file name example: saveKeywordFile("saveas.txt",$keywordArray) */ $keywordArray = $this->keywordArray; if (count($keywordArray) > 0) { if (file_exists($fileName)) { $errorManager->addError("Filename already in use in function saveKeywordFile()"); return 0; } $filePointer = fopen($fileName,"w"); if (!is_resource($filePointer)) { $errorManager->addError("Error creating file in function saveKeywordFile()"); return 0; } foreach ($keywordArray as $keyword) { fwrite($filePointer,$keyword."\n"); } return 1; } else { $errorManager->addError("The keyword array is empty in function saveKeywordFile()"); return 0; } } function loadKeywordFile($fileName) { /* loads a keyword file, returns array on success and 0 on failure example: loadKeywordFile("keywords.txt"); */ if (is_readable($fileName)) { $filePointer = fopen($fileName,"r"); if (!is_resource($filePointer)) { $errorManager->addError("Couldn't create file resource in loadKeywordFile()"); return 0; } while (!feof($filePointer)) { $fileData .= fgets($filePointer,128); } $keywordArray = explode("\n",$fileData); foreach ($keywordArray[0] as $keyword) { array_push ($this->keywordArray,$keyword); } return ($this->keywordArray); } else { $errorManager->addError("The file isn't readable in loadKeywordFile()"); return 0; } } function overtureKeywordSuggestions ($baseKeyword) { $curlHandle = curl_init(); curl_setopt($curlHandle,CURLOPT_URL,"http://inventory.uk.overture.com/d/searchinventory/suggestion/"); curl_setopt($curlHandle,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2"); curl_setopt($curlHandle,CURLOPT_RETURNTRANSFER,1); curl_setopt($curlHandle,CURLOPT_REFERER,"http://inventory.uk.overture.com/d/searchinventory/suggestion/"); curl_setopt($curlHandle,CURLOPT_POST,1); curl_setopt($curlHandle,CURLOPT_POSTFIELDS,"mkt=uk&lang=en_GB&term=".urlencode($baseKeyword)."&x=11&y=5"); $returnedHtml = curl_exec($curlHandle); preg_match_all("|<font face=\"verdana,sans-serif\" size=1 color=#000000>(.*)</a></td>|U",$returnedHtml,$keywordMatches); foreach ($keywordMatches[1] as $keyword) { if (array_search($keyword,$this->keywordArray)==0) { array_push($this->keywordArray,$keyword); } else { $errorManager->addError("Keyword already exist in array in function overtureKeywordSuggestions()"); return 0; } } return $this->keywordArray; } } ?> Code (markup):
It takes a base keyword and gets all the suggestions from overture, you can save to a file or load from a file. You can setup a loop to dig for deeper keywords after you get the first list also.
Hello, I need some guidlines on how to use this script. I've tried changing $filename to saveas.txt and keywords.txt , but it didn't work. Without a few instructions, it doesn't work.
Indomeso, As you're site is in Turkish (I think), could you give me the link to the download? Does it do the same thing - getting keywords from Overture?