diff --git a/spec/issue_spec.cr b/spec/issue_spec.cr index fe71e54..bd7d77e 100644 --- a/spec/issue_spec.cr +++ b/spec/issue_spec.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 diff --git a/src/infoparser.cr b/src/infoparser.cr index 514fb91..836c9e3 100644 --- a/src/infoparser.cr +++ b/src/infoparser.cr @@ -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("
", ", ").gsub("\n", " ") end diff --git a/src/issue.cr b/src/issue.cr index 4c31ad6..c8e004a 100644 --- a/src/issue.cr +++ b/src/issue.cr @@ -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