Jump to content

Extract Additional Results


mnybud

Recommended Posts

Can someone help me here or at least point me in the right direction?

I have the following code which takes the name of the domain from the url and extracts Overture keyword suggestions and prints them to a text file. I would like it to dig one level deeper instead of just returning the primary results. For instance if the domain was credit-cards.com it returns "credit cards, credit card offers, apply for a credit card, etc" and writes them to the text file. I want to not only save those terms to my text file but also search those terms in Overture and add them to the keyword text file as well so I can get the "long tail" terms as well as the main ones. Here is the code I am currently using. Any suggestions?

 

<?php 


// Set your file here.
$myFile = "keywords.txt";

// Get domain name
preg_match('@^(?:www\.|)([^\.]+)\.@i', $_SERVER['HTTP_HOST'], $matches);
$domain_name = $matches[1];
// Kepp only letters and numbers
$domain_name = preg_replace('/[^a-z0-9_]/i',' ',$domain_name);
$domain_name = ucwords($domain_name);
echo "<br>Domain: $domain_name<br>";
// Get overture suggestions (using the lib you found)
require_once('keyword_suggest.class.php'); 
$obj = new keyword_suggest($domain_name); 
$result = NULL;
if ($obj->execute()) { 
$result = $obj->get_keywords_weights();
// Write to file if all good.
    if (is_array($result)) {
	$fh = @fopen($myFile, 'w') or die("Can't open file: " . $myFile);
	foreach ($result as $key => $value) {
		fwrite($fh, ucwords($key) . "\n");
	}
	fclose($fh);
}
} else {
echo 'Could not load the overture page, please try again in a few seconds.';
}
// Let the people know we finished.
echo "All good.<br>" . rand();

?> 

Link to comment
https://forums.phpfreaks.com/topic/63458-extract-additional-results/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.