Parse title and publisher for issues

pull/8/head
Nemo 3 years ago
parent 6b278531fd
commit 7b48731afe
  1. 9
      spec/issue_spec.cr
  2. 4
      src/infoparser.cr
  3. 2
      src/issue.cr

@ -19,8 +19,7 @@ describe Muse::Dl::Issue do
issue.info["Print ISSN"].should eq "1531-2542"
issue.info["Launched on MUSE"].should eq "2020-02-05"
issue.info["Open Access"].should eq "No"
# issue.title.should eq "Volume 20, Number 1, January 2020"
issue.title.should eq "Volume 20, Number 1, January 2020"
end
# it "should parser summary" do
@ -29,7 +28,7 @@ describe Muse::Dl::Issue do
# EOT
# end
# it "should parse publisher" do
# issue.publisher.should eq "Johns Hopkins University Press"
# end
it "should parse publisher" do
issue.publisher.should eq "Johns Hopkins University Press"
end
end

@ -34,6 +34,10 @@ module Muse::Dl
myhtml.css("#book_about_info .title").map(&.inner_text).to_a[0].strip
end
def self.issue_title(myhtml : Myhtml::Parser)
myhtml.css(".card_text .title").map(&.inner_text).to_a[0].strip
end
def self.author(myhtml : Myhtml::Parser)
myhtml.css("#book_about_info .author").map(&.inner_text).to_a[0].strip.gsub("<BR>", ", ").gsub("\n", " ")
end

@ -17,7 +17,6 @@ module Muse::Dl
def initialize(id : String)
@id = id
@url = "https://muse.jhu.edu/issue/#{id}"
@title = "NA"
@info = Hash(String, String).new
@articles = [] of Muse::Dl::Article
end
@ -26,6 +25,7 @@ module Muse::Dl
html = Crest.get(url).to_s
h = Myhtml::Parser.new html
@info = InfoParser.infobox(h)
@title = InfoParser.issue_title(h)
@summary = InfoParser.summary(h)
@publisher = InfoParser.journal_publisher(h)
end

Loading…
Cancel
Save