Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. // Include the phpQuery library
  4. // Download at http://code.google.com/p/phpquery/
  5. include("phpQuery-onefile.php");
  6.  
  7. $country = "en";
  8. $domain = "stackoverflow.com";
  9. $keywords = "php google keyword rank checker";
  10. $firstnresults = 50;
  11.  
  12. $rank = 0;
  13. $urls = Array();
  14. $pages = ceil($firstnresults / 10);
  15. for($p = 0; $p < $pages; $p++){
  16. $start = $p * 10;
  17. $baseurl = "https://www.google.com/search?hl=".$country."&output=search&start=".$start."&q=".urlencode($keywords);
  18. $html = file_get_contents($baseurl);
  19.  
  20. $doc = phpQuery::newDocument($html);
  21.  
  22. foreach($doc['#ires cite'] as $node){
  23. $rank++;
  24. $url = $node->nodeValue;
  25. $urls[] = "[".$rank."] => ".$url;
  26. if(stripos($url, $domain) !== false){
  27. break(2);
  28. }
  29. }
  30. }
  31.  
  32. print "Country: ".$country."\n";
  33. print "Domain: ".$domain."\n";
  34. print "Keywords: ".$keywords."\n";
  35. print "Rank: ".$rank."\n";
  36. print "First urls:\n";
  37. print implode("\n", $urls)."\n";
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement