Home > Java > javaTutorial > body text

AS3 Post method analysis of crawling pages and reading progress bars

PHP中文网
Release: 2017-08-19 10:52:46
Original
1704 people have browsed it

This article introduces how to use as3 to crawl web page source code and monitor the byte progress of reading.

The code has been tested by me and is available for reference only.

The code is as follows:

System.useCodePage=true;
varvariables:URLVariables=newURLVariables();
variables.userName="Kakera";
variables.password="********";
varrequest:URLRequest=newURLRequest("http://www.baidu.com");
request.data=variables;
request.method=URLRequestMethod.POST;
varloader:URLLoader=newURLLoader();
loader.dataFormat=URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE,loader_complete);
loader.addEventListener(Event.OPEN,loader_open);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS,loader_httpStatus);
loader.addEventListener(ProgressEvent.PROGRESS,loader_progress);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,loader_security);
loader.addEventListener(IOErrorEvent.IO_ERROR,loader_ioError);
loader.load(request);
functionloader_complete(e:Event):void{
  trace("Event.COMPLETE");
  trace("目标文件的原始数据(纯文本):\n"+loader.data);
}
functionloader_open(e:Event):void{
  trace("Event.OPEN");trace("读取了的字节:"+loader.bytesLoaded);
}
functionloader_httpStatus(e:HTTPStatusEvent):void{
  trace("HTTPStatusEvent.HTTP_STATUS");
  trace("HTTP状态代码:"+e.status);
}
functionloader_progress(e:ProgressEvent):void{
  trace("ProgressEvent.PROGRESS");
  trace("读取了的字节:"+loader.bytesLoaded);
  trace("文件总字节:"+loader.bytesTotal);
}
functionloader_security(e:SecurityErrorEvent):void{
  trace("SecurityErrorEvent.SECURITY_ERROR");
}
functionloader_ioError(e:IOErrorEvent):void{
  trace("IOErrorEvent.IO_ERROR");
}
Copy after login

This article is provided by PHP Chinese website,

Article address: //m.sbmmt.com/java-article-377118 .html

To learn programming, come to PHP Chinese website m.sbmmt.com

The above is the detailed content of AS3 Post method analysis of crawling pages and reading progress bars. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template