Skip to content

Commit

Permalink
Add scraped_page_archiver
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtmtmtm committed Nov 29, 2016
1 parent 023c9dc commit b8f5880
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scraper.rb
Expand Up @@ -5,9 +5,10 @@
require 'scraped'
require 'scraperwiki'

require 'pry'
require 'open-uri/cached'
OpenURI::Cache.cache_path = '.cache'
# require 'pry'
# require 'open-uri/cached'
# OpenURI::Cache.cache_path = '.cache'
require 'scraped_page_archive/open-uri'

class String
def tidy
Expand All @@ -28,6 +29,7 @@ class ListPage < Scraped::HTML
end
end

# TODO: migrate to Scraped
def scrape_party(url, party)
puts party.to_s
noko = noko_for(url)
Expand All @@ -43,7 +45,7 @@ def scrape_party(url, party)
source: img_node.css('a/@href').text,
}
%i(image source).each { |i| data[i] = URI.join(url, URI.escape(data[i])).to_s unless data[i].to_s.empty? }
puts data
# puts data
ScraperWiki.save_sqlite([:name, :party], data)
end
end
Expand Down

0 comments on commit b8f5880

Please sign in to comment.