Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include the phpQuery library
- // Download at http://code.google.com/p/phpquery/
- include("phpQuery-onefile.php");
- $country = "en";
- $domain = "stackoverflow.com";
- $keywords = "php google keyword rank checker";
- $firstnresults = 50;
- $rank = 0;
- $urls = Array();
- $pages = ceil($firstnresults / 10);
- for($p = 0; $p < $pages; $p++){
- $start = $p * 10;
- $baseurl = "https://www.google.com/search?hl=".$country."&output=search&start=".$start."&q=".urlencode($keywords);
- $html = file_get_contents($baseurl);
- $doc = phpQuery::newDocument($html);
- foreach($doc['#ires cite'] as $node){
- $rank++;
- $url = $node->nodeValue;
- $urls[] = "[".$rank."] => ".$url;
- if(stripos($url, $domain) !== false){
- break(2);
- }
- }
- }
- print "Country: ".$country."\n";
- print "Domain: ".$domain."\n";
- print "Keywords: ".$keywords."\n";
- print "Rank: ".$rank."\n";
- print "First urls:\n";
- print implode("\n", $urls)."\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement