在as3中获取web的来源

Ale*_*rre 3 html httpwebrequest urlloader actionscript-3

这可能是不可能的事情,但我想问一下.有没有办法通过提供链接获取网页的HTML源?

Gio*_*Gio 9

当然有.我不明白为什么你会有这么多的反对票.无论如何,这是给你的一个片段:

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
}
Run Code Online (Sandbox Code Playgroud)

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