Google words' popularity

Can somebody write this for ruby?

<?php echo getscore ("ruby", "lang_en"); function getscore($wrd, $lng) { $wrd = str_replace(" ", "+", $wrd); $url = "http://www.google.com/search?q=%22" . $wrd . "%22&num=1&lr=" . $lng; $pg = file_get_contents($url); $sta = strpos($pg, "swrnum") + 7; $end = $sta + 10; $result = substr($pg, $sta, 10); return (int)$result; } ?>

On Mon, Mar 24, 2008 at 10:14 PM, Gi Ga [email protected] wrote:

$pg = file_get_contents($url);
$sta = strpos($pg, “swrnum”) + 7;
$end = $sta + 10;
$result = substr($pg, $sta, 10);
return (int)$result;
}

?>

require ‘open-uri’
require ‘uri’

def get_score(wrd, lng)
url =
http://www.google.com/search?q="#{URI.escape(wrd)}"&num=1&lr=#{URI.escape(lng)}
pg = open(url) {|io| io.read}
return $1.to_i if pg =~ /swrnum=(\d+)/
0 # or any default value
end

puts get_score(“ruby”, “lang_en”)

Thanks!!!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs