I need to download the image resources using Casper.js. I run into cases when the images are hosted on CDN with different domain name. Below for Twitter.com example and it doesn't work even using web-security=no: casperjs --ignore-ssl-errors=yes --web-security=no test.js
var casper = require("casper").create();
casper.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0');
casper.start();
casper.thenOpen("https://twitter.com/", function() {
casper.download("https://abs.twimg.com/a/1369885592/t1/img/front_page/cricket@2x.jpg", "test.jpg");
});
casper.run(function() {
casper.exit();
});
Can someone help me to work around this issue? Is it possible to use http request separately? I could do this and it would work
casper.thenOpen("https://abs.twimg.com", function() {
casper.download("https://abs.twimg.com/a/1369885592/t1/img/front_page/cricket@2x.jpg", "test.jpg");
});
But that is way too much overhead.
UPDATE 1:
I am running phantom.js 1.9.0 and casper.js 1.0.2 on Windows 7.
This is the error I got (no file being captured of course):
Remote: sendAJAX(): Using HTTP method: 'GET'
Remote: getBinary(): Unfortunately, casperjs cannot make cross domain ajax reque
sts
Remote: getBinary(): Error while fetching https://abs.twimg.com/a/1369885592/t1/
img/front_page/cricket@2x.jpg: Error: NETWORK_ERR: XMLHttpRequest Exception 101