Sha256: eb56225275f403571db84e67f2991db39c62952bd839951aae18cf938b09c9bc

Contents?: true

Size: 843 Bytes

Versions: 5

Compression:

Stored size: 843 Bytes

Contents

class DeveloperNewsCliApp::FreeCodeCampScrapper
	@@all = []

	def get_page
		Nokogiri::HTML(open("https://medium.freecodecamp.org/"))
	end

	def get_articles
		self.get_page.css(".postArticle")
	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.read_time = article.css(".readingTime").attribute("title").value
			a.url = article.css(".postArticle-readMore a").attribute("href").value
			a.website = "FreeCodeCamp"
			a.subtitle = article.css("h4").text == "" ? nil : article.css("h4").text
			a.trailing = article.css("p").text == "" ? nil : article.css("p").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/FreeCodeCampScrapper.rb
developer_news_cli_app-0.1.4 lib/developer_news_cli_app/FreeCodeCampScrapper.rb
developer_news_cli_app-0.1.3 lib/developer_news_cli_app/FreeCodeCampScrapper.rb
developer_news_cli_app-0.1.1 lib/developer_news_cli_app/FreeCodeCampScrapper.rb
developer_news_cli_app-0.1.0 lib/developer_news_cli_app/FreeCodeCampScrapper.rb