Last active
August 29, 2015 13:56
Revisions
-
workmad3 revised this gist
Feb 13, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ namespace :scrape do desc "Take a screenshot of a url using Phantomjs" task :screenshots => :environment do require 'capybara' require 'poltergeist/capybara' include Capybara::DSL Capybara.default_driver = :poltergeist articles = Article.order('zscore DESC').limit(3) articles.each_with_index do |article, i| -
workmad3 revised this gist
Feb 13, 2014 . 2 changed files with 3 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,12 @@ namespace :scrape do desc "Take a screenshot of a url using Phantomjs" task :screenshots => :environment do include Capybara::DSL articles = Article.order('zscore DESC').limit(3) articles.each_with_index do |article, i| visit article.url screenshot_and_save_page sleep 4 end end -
DaniG2k revised this gist
Feb 13, 2014 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ page = require('webpage').create() url = phantom.args[1] output = phantom.args[2] page.open(url, (status)-> console.log "Status: #{status}" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,12 @@ namespace :scrape do desc "Take a screenshot of a url using Phantomjs" task :screenshots => :environment do f = File.join(Rails.root, 'app', 'assets', 'javascripts', 'screenshot.js.coffee').gsub(/ /, '\ ') articles = Article.order('zscore DESC').limit(3) articles.each_with_index do |article, i| `phantomjs #{f} #{article.url} screenshot-#{i}` sleep 4 end end end -
DaniG2k revised this gist
Feb 13, 2014 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ page = require('webpage').create() url = phantom.args[0] output = phantom.args[1] page.open(url, (status)-> console.log "Status: #{status}" page.render "#{output}.png" console.log "Took screenshot #{output}.png" console.log 'Exiting...' phantom.exit() ) -
DaniG2k created this gist
Feb 13, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ 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