nijie: fetch artist commentary.

This commit is contained in:
evazion
2017-06-20 14:55:46 -05:00
parent 05f7226fdd
commit 25e7db860a
2 changed files with 16 additions and 0 deletions

View File

@@ -39,10 +39,18 @@ module Sources
@artist_name, @profile_url = get_profile_from_page(page)
@image_url = get_image_url_from_page(page)
@tags = get_tags_from_page(page)
@artist_commentary_title, @artist_commentary_desc = get_commentary_from_page(page)
end
protected
def get_commentary_from_page(page)
title = page.search("h2.illust_title").text
desc = page.search('meta[property="og:description"]').attr("content").value
[title, desc]
end
def get_profile_from_page(page)
links = page.search("a.name")

View File

@@ -23,6 +23,14 @@ module Sources
should "get the tags" do
assert_equal([["眼鏡", "http://nijie.info/search.php?word=%E7%9C%BC%E9%8F%A1"], ["リトルウィッチアカデミア", "http://nijie.info/search.php?word=%E3%83%AA%E3%83%88%E3%83%AB%E3%82%A6%E3%82%A3%E3%83%83%E3%83%81%E3%82%A2%E3%82%AB%E3%83%87%E3%83%9F%E3%82%A2"], ["アーシュラ先生", "http://nijie.info/search.php?word=%E3%82%A2%E3%83%BC%E3%82%B7%E3%83%A5%E3%83%A9%E5%85%88%E7%94%9F"]], @site.tags)
end
should "get the commentary" do
title = "ジャージの下は"
desc = "「リトルウィッチアカデミア」から無自覚サキュバスぶりを発揮するアーシュラ先生です"
assert_equal(title, @site.artist_commentary_title)
assert_equal(desc, @site.artist_commentary_desc)
end
end
context "The source site for a nijie referer url" do