phantomjs/examples/imagebin.coffee

21 lines
638 B
CoffeeScript
Raw Normal View History

2011-06-07 05:18:22 +04:00
# Upload an image to imagebin.org
page = require('webpage').create()
system = require 'system'
2011-06-07 05:18:22 +04:00
if system.args.length isnt 2
2011-06-07 05:18:22 +04:00
console.log 'Usage: imagebin.coffee filename'
phantom.exit 1
2011-06-07 05:18:22 +04:00
else
fname = system.args[1]
2011-06-07 05:18:22 +04:00
page.open 'http://imagebin.org/index.php?page=add', ->
page.uploadFile 'input[name=image]', fname
page.evaluate ->
document.querySelector('input[name=nickname]').value = 'phantom'
document.querySelector('input[name=disclaimer_agree]').click()
document.querySelector('form').submit()
window.setTimeout ->
phantom.exit()
, 3000