Class: Staticfy::Crawler
- Inherits:
-
Object
- Object
- Staticfy::Crawler
- Defined in:
- lib/staticfy/crawler.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #crawl ⇒ Object
-
#initialize(url, options = {}) ⇒ Crawler
constructor
A new instance of Crawler.
Constructor Details
#initialize(url, options = {}) ⇒ Crawler
Returns a new instance of Crawler.
25 26 27 28 |
# File 'lib/staticfy/crawler.rb', line 25 def initialize(url, = {}) @url = url @options = end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
23 24 25 |
# File 'lib/staticfy/crawler.rb', line 23 def url @url end |
Instance Method Details
#crawl ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/staticfy/crawler.rb', line 30 def crawl Anemone.crawl(url) do |anemone| anemone.on_every_page do |page| local_path = File.join(@options[:output], page.local_uri) File.open(local_path, "wb") do |file| file << page.local_body end puts "Saved #{local_path}" end end end |