Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/imagebin.js
164 views
1
// Upload an image to imagebin.org
2
3
var page = require('webpage').create(),
4
system = require('system'),
5
fname;
6
7
if (system.args.length !== 2) {
8
console.log('Usage: imagebin.js filename');
9
phantom.exit(1);
10
} else {
11
fname = system.args[1];
12
page.open("http://imagebin.org/index.php?page=add", function () {
13
page.uploadFile('input[name=image]', fname);
14
page.evaluate(function () {
15
document.querySelector('input[name=nickname]').value = 'phantom';
16
document.querySelector('input[name=disclaimer_agree]').click()
17
document.querySelector('form').submit();
18
});
19
window.setTimeout(function () {
20
phantom.exit();
21
}, 3000);
22
});
23
}
24
25