Casper.js を使用して画像リソースをダウンロードする必要があります。イメージが別のドメイン名の CDN でホストされている場合があります。以下は Twitter.com の例で、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();
});
誰かがこの問題を回避するのを手伝ってくれますか? http request
別々に使用することは可能ですか?私はこれを行うことができ、それはうまくいくでしょう
casper.thenOpen("https://abs.twimg.com", function() {
casper.download("https://abs.twimg.com/a/1369885592/t1/img/front_page/cricket@2x.jpg", "test.jpg");
});
しかし、それはあまりにも多くのオーバーヘッドです。
更新 1:
Windows 7で phantom.js 1.9.0 と casper.js 1.0.2 を実行しています。
これは私が得たエラーです(もちろんファイルはキャプチャされていません):
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