Note. I have already reviewed these links:
CasperJS and file upload via iFrame and JavaScript
Submitting a form using casperjs
I thought they were ideal for what I was trying to achieve, but my efforts were futile.
I am trying to download mp3 to my file system via https://www.youtube2mp3.cc/#conversion and I am trying to execute this headless via CasperJS.
Here is my code:
var casper = require('casper').create({verbose: true , logLevel: "debug" });
var fs = require('fs');
casper.start('http://www.video2mp3.de/');
casper.waitForSelector("#converter > form");
casper.fill('#converter > form', { video: 'https://www.youtube.com/watch?v=VoaUYcwEpSw' }, true);
casper.waitForSelector("#file");
var url = casper.getElementAttribute('#file','href');
var mp3 = fs.absolute("unstoppable.mp3");
casper.then(function() { this.download(url, mp3); });
casper.run();
I think I'm a little naive, thinking that it will be so simple, but I can not find my mistakes. The debugger didn't help much. I ran my file with the following command in my terminal:
casperjs --web-security=no sample.js
Any help would be appreciated.
source
share