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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.