Html 在as3中获取web的源代码

Html 在as3中获取web的源代码,html,actionscript-3,httpwebrequest,urlloader,Html,Actionscript 3,Httpwebrequest,Urlloader,这可能是不可能的事,但我想问一下。 有没有办法通过提供链接来获取网页的html源代码?当然有。我不明白你为什么得到这么多反对票。无论如何,这里有一个片段给你: var pageLoader:URLLoader = new URLLoader(); //make a loader that will load a page var pageRequest:URLRequest = new URLRequest("http://google.com"); //make a request with

这可能是不可能的事,但我想问一下。
有没有办法通过提供链接来获取网页的html源代码?

当然有。我不明白你为什么得到这么多反对票。无论如何,这里有一个片段给你:

var pageLoader:URLLoader = new URLLoader(); //make a loader that will load a page
var pageRequest:URLRequest = new URLRequest("http://google.com"); //make a request with a url to page
pageRequest.method = URLRequestMethod.GET; //set request's html request method to GET

pageLoader.addEventListener(Event.COMPLETE, onPageLoaded); //listen for page load
pageLoader.load(pageRequest); //actually load the page

function onPageLoaded(e:Event):void
{
    trace(pageLoader.data); //handle the data from the loader
}

您还可以使用
e.target
从处理函数获取对
pageLoader
实例的引用。祝你好运。

如果我的回答对你有帮助的话,你至少可以接受。如果没有,请告诉我。