class WebsiteWorth::Scraper
Attributes
alexa_rank[RW]
attributes
attri[RW]
attributes
overall_revenue[RW]
attributes
rev_daily[RW]
attributes
rev_monthly[RW]
attributes
rev_yearly[RW]
attributes
site_name[RW]
attributes
views_daily[RW]
attributes
views_monthly[RW]
attributes
views_yearly[RW]
attributes
visits_daily[RW]
attributes
visits_monthly[RW]
attributes
visits_yearly[RW]
attributes
Public Instance Methods
get_data_source()
click to toggle source
# File lib/website_worth/scraper.rb, line 24 def get_data_source @site_name = WebsiteWorth::User.gives_a_site_name @site = Nokogiri::HTML(open("https://www.worthofweb.com/website-value/#{site_name}/")) end
get_site_attributes()
click to toggle source
# File lib/website_worth/scraper.rb, line 89 def get_site_attributes @attri = [] attri end
get_user_site_data()
click to toggle source
# File lib/website_worth/scraper.rb, line 17 def get_user_site_data get_data_source pin_point_data print_data get_site_attributes end
gets_big_name_data()
click to toggle source
Priority Methods
# File lib/website_worth/scraper.rb, line 8 def gets_big_name_data urls = ["https://www.worthofweb.com/website-value/google/", "https://www.worthofweb.com/website-value/amazon/", "https://www.worthofweb.com/website-value/facebook/", "https://www.worthofweb.com/website-value/youtube/"] worth = [] urls.each do |url| worth << Nokogiri::HTML(open(url)).css('div.card-body div.side-left p:nth-of-type(2)')[0].text end worth end
pin_point_data()
click to toggle source
# File lib/website_worth/scraper.rb, line 29 def pin_point_data # ========== Revenue ========== # begin @overall_revenue = @site.css('div.card-body div.side-left p:nth-of-type(2)')[0].text rescue NoMethodError puts "Sorry, it seems that the website you entered was invalid" WebsiteWorth::CLI.new.call end @rev_daily = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[0].text @rev_monthly = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[1].text @rev_yearly = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[2].text # ========== Visits ========== # @visits_daily = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[3].text @visits_monthly = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[5].text @visits_yearly = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[7].text # ========== Page Views ========== # @views_daily = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[4].text @views_monthly = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[6].text @views_yearly = @site.css('div.card-body .col-md-4 p:nth-of-type(2)')[8].text # ========== Alexa Rank ========== # @alexa_rank = @site.css('div.row')[25].text.gsub(/\R+/, ' ').strip.split[9] end
print_data()
click to toggle source
# File lib/website_worth/scraper.rb, line 52 def print_data puts "\n #{@site_name.upcase}" get_site_attributes << @site_name.upcase puts puts "========== REVENUE ==========" puts puts "===== Overall/ #{@overall_revenue} =====" get_site_attributes << @overall_revenue puts "===== Daily/ #{@rev_daily} =====" get_site_attributes << @rev_daily puts "===== Monthly/ #{@rev_monthly} =====" get_site_attributes << @rev_monthly puts "===== Yearly/ #{@rev_yearly} =====" get_site_attributes << @rev_yearly puts puts "========== VISITS ==========" puts puts "===== Daily/ #{@visits_daily} =====" get_site_attributes << @visits_daily puts "===== Monthly/ #{@visits_monthly} =====" get_site_attributes << @visits_monthly puts "===== Yearly/ #{@visits_yearly} =====" get_site_attributes << @visits_yearly puts puts "========== PAGE VIEWS ==========" puts puts "===== Daily/ #{@views_daily} =====" get_site_attributes << @views_daily puts "===== Monthly/ #{@views_monthly} =====" get_site_attributes << @views_monthly puts "===== Yearly/ #{@views_yearly} =====" get_site_attributes << @views_yearly puts puts "========== Alexa Rank/ #{@alexa_rank} ==========" get_site_attributes << @alexa_rank end