Sha256: 38bff489fc8012513132bf9f3f20b80faed04e35743f2ae03d459849dd4d526f

Contents?: true

Size: 688 Bytes

Versions: 5

Compression:

Stored size: 688 Bytes

Contents

class DeveloperNewsCliApp::HackerNoonScrapper
	@@all = []

	def get_page
		Nokogiri::HTML(open("https://hackernoon.com/"))
	end

	def get_articles
		self.get_page.css(".js-trackedPost")
	end

	def make_article
		self.get_articles.each do |article|
			a = DeveloperNewsCliApp::Article.new
			a.title = article.css("h3").text
			a.author = article.css(".ds-link").text
			a.date = article.css("time").text
			a.url = article.css("a").attribute("href").value
			a.website = "HackerNoon"
			a.trailing = article.css(".u-fontSize18").text == "" ? nil : article.css(".u-fontSize18").text
			@@all << a
		end
	end

	def self.articles
		@@all
	end

	def self.article_count
		@@all.count
	end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
developer_news_cli_app-0.1.5 lib/developer_news_cli_app/HackerNoonScrapper.rb
developer_news_cli_app-0.1.4 lib/developer_news_cli_app/HackerNoonScrapper.rb
developer_news_cli_app-0.1.3 lib/developer_news_cli_app/HackerNoonScrapper.rb
developer_news_cli_app-0.1.1 lib/developer_news_cli_app/HackerNoonScrapper.rb
developer_news_cli_app-0.1.0 lib/developer_news_cli_app/HackerNoonScrapper.rb