Class: SakamichiScraper::Sakurazaka

Inherits:
Base
  • Object
show all
Defined in:
lib/sakamichi_scraper/sakurazaka.rb

Instance Method Summary collapse

Methods inherited from Base

#blog_list_page, #blog_top_page, #download_images_from_url_list, #exclude_img_path, #exec_date, #format_content, #format_timestamp, #get_content, #image_file_path, #image_urls_from_article_url, #init_url_from_yml, #mkdir_today_file_path

Constructor Details

#initializeSakurazaka

Returns a new instance of Sakurazaka.



5
6
7
# File 'lib/sakamichi_scraper/sakurazaka.rb', line 5

def initialize
  super("sakurazaka")
end

Instance Method Details

#blog_top_page_titleObject



9
10
11
# File 'lib/sakamichi_scraper/sakurazaka.rb', line 9

def blog_top_page_title
  Nokogiri::HTML.parse(blog_top_page, nil, nil).title
end

#newest_blog_titleObject



13
14
15
# File 'lib/sakamichi_scraper/sakurazaka.rb', line 13

def newest_blog_title
  Nokogiri.parse(blog_list_page, nil, nil).at_css(".date-title > .title").children.to_s
end

#picture_in_newest_articleObject



29
30
31
32
33
34
35
36
# File 'lib/sakamichi_scraper/sakurazaka.rb', line 29

def picture_in_newest_article
  newest_article_url = article_urls_from_list_page(blog_list_page).first
  article_html = get_content(newest_article_url)
  image_urls = image_urls_from_article_url(article_html, "div.box-article")

  mkdir_today_file_path unless Dir.exist?(image_file_path)
  download_images_from_url_list(image_urls)
end

#recent_blog_infoObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sakamichi_scraper/sakurazaka.rb', line 17

def recent_blog_info
  res = []
  Nokogiri.parse(blog_list_page, nil, nil).css(".com-blog-part.box4.fxpc > li").each do |c|
    info = {
      member: c.css(".prof-in.fx > .name").children.to_s,
      title:  c.css(".date-title > .title").children.to_s,
      timestamp: c.css(".date.wf-a").children.to_s
    }
    res << info
  end
end