class FacebookProfileScraper

Public Class Methods

new(facebook_profile) click to toggle source
# File lib/facebook-profile-scraper.rb, line 5
def initialize(facebook_profile)
  begin
    # Download page (GET REQEUST)
    @page = HTTParty.get(facebook_profile)
    # Parse the page with Nokogiri
    @parsed_page = Nokogiri::HTML(@page)
  rescue
  end
end

Public Instance Methods

about() click to toggle source
# File lib/facebook-profile-scraper.rb, line 35
def about
  begin
    # Parse "about" from profile
    @parsed_page.css('#pagelet_bio span._c24._50f4')[0].text
  rescue
  end
end
city() click to toggle source
# File lib/facebook-profile-scraper.rb, line 28
def city
  begin
    # Parse first city from profile
    @parsed_page.css('#pagelet_hometown span._50f5._50f7')[0].css('a').text
  rescue
  end
end
name() click to toggle source
# File lib/facebook-profile-scraper.rb, line 14
def name
  begin
    # Parse full name from profile
    @parsed_page.css('#fb-timeline-cover-name').text
  rescue
  end
end
picture() click to toggle source
# File lib/facebook-profile-scraper.rb, line 21
def picture
  begin
    # Parse profile picture from profile
    @parsed_page.css('img.profilePic.img').attr('src')
  rescue
  end
end
quote() click to toggle source
# File lib/facebook-profile-scraper.rb, line 42
def quote
  begin
    # Parse "quote" from profile
    @parsed_page.css('#pagelet_quotes span._c24._50f4')[0].text
  rescue
  end
end