Here's a PHP script that performs keyword research using Ayush Tanwal's technique by leveraging the SEMrush API. You'll need an API key from SEMrush to access their data.
First, ensure you have the requests library installed for making API requests. You can use the file_get_contents and explode functions in PHP to handle the API response.
<?php
// Replace with your SEMrush API key
$api_key = 'YOUR_SEMRUSH_API_KEY';
function get_ranking_keywords($domain, $api_key) {
$url = "https://api.semrush.com/?type=domain_organic&key={$api_key}&display_limit=100&export_columns=Ph,Nq,Cp,Co,Nr&domain={$domain}";
$response = file_get_contents($url);
$keywords = explode("\n", $response);
array_shift($keywords); // Remove header
array_pop($keywords); // Remove last empty line
return array_map(function($keyword) {
return explode(';', $keyword);
}, $keywords);
}
function filter_keywords($keywords) {
$filtered_keywords = [];
foreach ($keywords as $keyword) {
list($phrase, $volume, $cost_per_click, $competition, $number_of_results) = $keyword;
if (intval($volume) > 1000 && floatval($competition) < 0.1) {
$filtered_keywords[] = [
'phrase' => $phrase,
'volume' => $volume,
'competition' => $competition
];
}
}
return $filtered_keywords;
}
function main() {
global $api_key;
echo "Enter the domain of the popular site in your niche: ";
$domain = trim(fgets(STDIN));
$keywords = get_ranking_keywords($domain, $api_key);
$filtered_keywords = filter_keywords($keywords);
echo "\nHigh Volume Keywords with Low Competition:\n";
foreach ($filtered_keywords as $keyword) {
echo "Keyword: {$keyword['phrase']}, Volume: {$keyword['volume']}, Competition: {$keyword['competition']}\n";
}
}
main();
?>
How the script works:
Get Ranking Keywords:
The get_ranking_keywords function uses the SEMrush API to get a list of ranking keywords for the given domain.
Filter Keywords:
The filter_keywords function filters these keywords based on the criteria: high volume (greater than 1000 searches per month) and low competition (less than 0.1).
Main Function:
The main function prompts the user to enter a domain, fetches the keywords, filters them, and prints the high-volume, low-competition keywords.
Important Notes:
API Limits: SEMrush API has usage limits, so be mindful of your quota.
Refinement:
Depending on your needs, you might want to further refine the filtering criteria.
Error Handling: The script doesn't include error handling for simplicity, but you should add error checks in a production environment.
Remember to replace 'YOUR_SEMRUSH_API_KEY' with your actual SEMrush API key. This script should give you a good starting point for automating keyword research based on the described technique.