Skip to content

Instantly share code, notes, and snippets.

@workmad3
Last active August 29, 2015 13:56
Show Gist options
  • Save workmad3/8974238 to your computer and use it in GitHub Desktop.
Save workmad3/8974238 to your computer and use it in GitHub Desktop.
namespace :scrape do
desc "Take a screenshot of a url using Phantomjs"
task :screenshots => :environment do
asset = ActionController::Base.helpers.asset_path('screenshot.js.coffee')
f = File.join(Rails.root, 'app', asset).gsub(/ /, '\ ')
articles = Article.order('zscore DESC').limit(3)
articles.each_with_index do |article, i|
`phantomjs #{f} #{article.url} screenshot-#{i}`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment