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