我正在尝试使用 actionscript 抓取网页,但不断收到此错误(尝试抓取 github.com 的示例):
[SWF] /get-webpage.swf - 解压后 2,708 字节错误:来自 http://localhost:4567/get-webpage.swf的请求者对http://github.com的资源请求 因缺乏政策而被拒绝文件权限。
* 违反安全沙箱 *与http://github.com的 连接停止 - 不允许来自http://localhost:4567/get-webpage.swf
有什么方法可以在 Actionscript 中进行这项工作吗?文件如何crossdomain.xml
发挥作用?据我了解,网站将 a 作为crossdomain.xml
其根目录,指定 swf 可以访问他们的内容。那是对的吗?我需要做什么才能完成上述工作?我正在使用的代码基本上是这样的:
var request:URLRequest = new URLRequest("http://github.com")
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, complete);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, error);
loader.load(request);
function complete(event:Event):void {
trace(event.target.data);
}
function error(event:SecurityErrorEvent):void {
trace(event.text);
}
在 HTML 文件中使用这个:
var flashvars = {};
var params = {allowscriptaccess: "always"};
var attributes = {id: "my_flash", name: "my_flash"};
swfobject.embedSWF("/get-webpage.swf", "flash_content", "50%", "50%", "10.0.0", "playerProductInstall.swf", flashvars, params, attributes, swfHasLoadedSir);
是否有可能绕过该安全错误?