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

StackOverflow https://stackoverflow.com/questions/3719144

  •  03-10-2019
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução

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)
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top