tags:

views:

23

answers:

1

Hi all,

I have a large list of things I want to search for in scholar.google.com (a list of chromosomal regions), and I only want to the number of results for each search term. Does anyone know what the best way is to do this? Thanks in advance!

A: 

You can use this ruby script

#!/usr/bin/ruby

require 'net/http'
require 'uri'
def number_of_results(search_query)
    url = 'http://scholar.google.com/scholar'
    query = '?hl=en&btnG=Search&as_sdt=2001&as_sdtp=on&q='+search_query

    url = URI.parse(url)
    page = Net::HTTP.new(url.host).get(url.path + query).body

    if page =~ /of about <b>([0-9,]*)<\/b>\./
      return $1
    else
      return nil
    end

number_of_results(ARGV.join(' '))

and call from terminal/console search.rb search term

and if you have array of terms

['foo','bar','baz','quux'].each {|term|
  puts number_of_results(term)
}
jcubic