首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

perl怎么得到源代码

2012-02-23 
perl如何得到源代码Perl code#!/usr/bin/perluse warningsuse strictuse Win32::OLEmy $urlwww.163.c

perl如何得到源代码

Perl code
    #!/usr/bin/perl    use warnings;    use strict;    use Win32::OLE;        my $url="www.163.com";    my $ie = Win32::OLE->new ('InternetExplorer.Application.1', 'Quit')    ||  die "CreateObject: " . Win32::OLE->LastError ;    $ie->{Visible} = 1; #0    $ie->Navigate($url);    ????????    undef($ie);


以上 ????????处使用什么方法可以得到此网页的源代码。

不要使用以下方法
Perl code
use LWP::Simple;              use LWP::UserAgent;           use HTTP::Request::Common;    use Socket;                   my $ua = new LWP::UserAgent;                                    $ua->agent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1");                                                                my $req = new HTTP::Request GET =>$url;                         my $res     = $ua->request($req);                               my $content = $res->content;      


原因是有些网站需要验证,这个方法得不到真正的内容。所以我在手动输入验证码访问网站后再让perl去访问该网站,进而得到该网站的源代码。我现在的要求是打开网站后如何得到源代码。不知这么说各位看官明白没,不懂请留言跟进,我随时关注~~~~~~~  


[解决办法]
自己搜下InternetExplorer.Application,看下微软的文档。都是通用的。一般是outerHTML什么的。

热点排行