Class: SocialScraper::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/social_scraper/scraper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Scraper

Returns a new instance of Scraper.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/social_scraper/scraper.rb', line 9

def initialize(url)
  @url = URI.parse(url).scheme.nil? ? 'http://' + url : url
  puts "URL IS: #{@url}"
  # @data = Hashie::Rash.new('url' => @url)


  # doc = Nokogiri::HTML(open(@url))
  # 
  # doc.xpath('//a').each do |link|
  #   href = link.attributes["href"]
  # 
  #   # check for a twitter link
  #   if href.present? && href.value =~ /twitter/
  #     # assume http://twitter.com/xyz, get the account: xyz
  #     junk,@twitter_account = href.value.split("twitter.com/")
  #   end
  # end


end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/social_scraper/scraper.rb', line 7

def url
  @url
end