Skip to content

Instantly share code, notes, and snippets.

@timchunght
Forked from hidenba/webkit2png.rb
Created October 28, 2015 00:25
Show Gist options
  • Save timchunght/ca36f71779e254355db7 to your computer and use it in GitHub Desktop.
Save timchunght/ca36f71779e254355db7 to your computer and use it in GitHub Desktop.
class WebkitToPng
def self.create(urls, options={})
urls.each do |url|
puts "convert #{url} to #{options[:dir]}"
url.sub!('//', "//#{options[:auth]}@") if options[:auth]
op = "-F -D #{options[:dir]} -o #{url.split('/').last}"
op += " --user-agent='#{user_agent}'" if options[:mobile]
exec(url, op)
end
end
private
def self.exec(url, options)
`/Users/hidenba/project/webkit2png/webkit2png #{options} #{url}`
end
def self.user_agent
'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53'
end
end
WebkitToPng.create(new_urls, {auth: auth, mobile: false, dir: './pc_new_url'})
WebkitToPng.create(new_urls, {auth: auth, mobile: false, dir: './pc_old_url'})
WebkitToPng.create(new_urls, {auth: auth, mobile: true, dir: './mobile_new_url'})
WebkitToPng.create(new_urls, {auth: auth, mobile: true, dir: './mobile_old_url'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment