开发者

How do I do a Google scholar batch search, and get only the number of results back?

I have a large list of things I want to search for in scholar.google.com (a list of chromosomal r开发者_运维知识库egions), and I only want to the number of results for each search term. Does anyone know what the best way is to do this?


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)
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜