module IEEEPaperDownloader
Constants
- API_KEY
- API_URI
- VERSION
Public Class Methods
download(article_number, filename)
click to toggle source
# File lib/ieee_paper_downloader.rb, line 19 def download(article_number, filename) uri = "http://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&isnumber=&arnumber=#{article_number}" system("echo '#{uri}' | xargs wget -O '#{filename}'") end
read_csv(csv_path)
click to toggle source
# File lib/ieee_paper_downloader.rb, line 24 def read_csv(csv_path) csv_data = CSV.read(csv_path, headers: true) articles = csv_data.map do |record| pdf_link = record.find do |element| element[0].include?('PDF Link') end[1] article_number = Hash[URI.decode_www_form(URI.parse(pdf_link).query)]['arnumber'] title = record.find do |element| element[0].include?('Document Title') end[1].gsub(/\//, ' and ') { 'article_number' => article_number, 'title' => title } end articles end
search(query_text)
click to toggle source
# File lib/ieee_paper_downloader.rb, line 12 def search(query_text) raise "環境変数IEEE_XPLORE_APIがセットされていません" if API_KEY.nil? uri = "#{API_URI}?querytext=#{query_text}&format=json&subscribed=true&apikey=#{API_KEY}" result = JSON.parse(Net::HTTP.get(URI.parse(uri))) result end
Private Instance Methods
download(article_number, filename)
click to toggle source
# File lib/ieee_paper_downloader.rb, line 19 def download(article_number, filename) uri = "http://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&isnumber=&arnumber=#{article_number}" system("echo '#{uri}' | xargs wget -O '#{filename}'") end
read_csv(csv_path)
click to toggle source
# File lib/ieee_paper_downloader.rb, line 24 def read_csv(csv_path) csv_data = CSV.read(csv_path, headers: true) articles = csv_data.map do |record| pdf_link = record.find do |element| element[0].include?('PDF Link') end[1] article_number = Hash[URI.decode_www_form(URI.parse(pdf_link).query)]['arnumber'] title = record.find do |element| element[0].include?('Document Title') end[1].gsub(/\//, ' and ') { 'article_number' => article_number, 'title' => title } end articles end
search(query_text)
click to toggle source
# File lib/ieee_paper_downloader.rb, line 12 def search(query_text) raise "環境変数IEEE_XPLORE_APIがセットされていません" if API_KEY.nil? uri = "#{API_URI}?querytext=#{query_text}&format=json&subscribed=true&apikey=#{API_KEY}" result = JSON.parse(Net::HTTP.get(URI.parse(uri))) result end