SEO Keyword Spy PHP Class

Last Update
20 February 2012
Regular License
$6
Extended License
$30
Sales
27

Keywords and keyword density are common terms in SEO . You want to know your keywords and keyword density for your Web pages and your competitor pages. SEO Keyword Spy is a PHP class you can plug in to your programs that saves you time with keyword analysis functions. The tool even has a graph you can use to print out analysis and display it on the screen, or you can retrieve the keywords and use them in your own programs.

Features

- Retrieve keyword phrases from a URL - Get percentages (keyword density) for each keyword in the URL content - Display a graph that shows the most common keywords and the keyword density or use the keyword density for your own program’s purposes - Get plain text content you can use to store in a database - Filter out common keywords you don’t need - Customize the keywords you want to filter out using the stopwords.txt (some common words already included) - Requires cURL

Installation

The demo link has a GUI for you to test it out, but all you need for installation is the “keywords” directory, which includes keywords.php, stopwords.txt and the HTML DOM component.

The project has the following structure:

|- keywordsgui.php |- (dir)keywords | —|- keywords.php | —|- stopwords.txt | —|- (dir)htmldom | —|-| - simple_html_dom.php Copy the keywords directory to your project folder.

SEO Keyword Spy also uses cURL, so your server must have it installed. This class has been tested on PHP4 and PHP5 shared hosts.

How to Use the Class

After you copy the keywords directory to your project, you included it in your project. Add the following line of code to the PHP code file you want to use to retrieve the keywords:

include(‘keywords/keywords.php’); Now, you can use the class. The first step is to instantiate the class. Add the following code to your PHP :

$content = new webkeywords(); Function: Get webpage content

This function is useful if you just want the content from the remote page. The following code retrieves the content in plain text:

$plaintext = $content->getContent($url); Function: Get keyword density

This function returns the percentage for each keyword. All keywords are returned except those set up in the stopwords.txt file (more about this file later). The function returns an array of keywords. To retrieve the list of keywords and loop through each keyword and its density value, add the following code:

$stats = $content->getStatsOnly(); //gets a list of keywords and densities foreach($stats as $key => $value) //displays keyword ($key) and the density ($value) { echo $key.”: ”.$value.”%”; } Function: Get the word count for the web page

This function just returns the word count for the page content. Add the following code to get the content:

$wordcount = $content->getWordCount(); Function: Graph the results

This function is optional, if you want to display a bar graph that represents the keyword density. You can only graph up to 20 keywords. The integer passed to to the function must be a number from 1 to 20. Add the following code to display a graph on your web page:

$content->graphit($numberofgraphs); stopwords.txt

SEO Keyword Spy includes a text file you use to filter out words you don’t want to use. Some words are already added. The words must be contained in quotes, and separated by commas. You can add or delete keywords. The following is an example of the first line of the file:

“an”, “a”, “the”, “and”, “but”, “or”, “because”, “so”, “your”, “you”, “for”, “what”, “we”,