Created
          September 30, 2015 05:27 
        
      - 
      
- 
        Save gn-spawn/9bb3604e606dab57f8a8 to your computer and use it in GitHub Desktop. 
    sample
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'open-uri' | |
| require 'nokogiri' | |
| URL = 'http://heavens-fox.blog.jp/' | |
| html = open(URL) { |f| f.read } | |
| doc = Nokogiri::HTML.parse(html, nil) | |
| class BabymetalArticle | |
| def initialize(article) | |
| @title = article.css("h1.article-title > a").text | |
| @summary = article.css("div.article-body-inner").text | |
| @comments = article.css("li.article-comment-count > dl > dd >a").text.to_i | |
| end | |
| def put_console | |
| puts @title | |
| puts @summary | |
| puts @comments | |
| end | |
| end | |
| articles = doc.css("div.article-inner").map do |article| | |
| BabymetalArticle.new article | |
| end | |
| articles.each {|article| article.put_console} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment