- 论坛徽章:
- 0
|
大家好,想做一个跟simsimi聊天的perl程序,源码如下:- #!/usr/bin/perl
- use strict;
- use warnings;
- use LWP;
- use HTTP::Cookies;
- use HTTP::Response;
- use LWP::ConnCache;
- use Encode;
- use FileHandle;
- my $lwp = LWP::UserAgent->new;
- my $conncache = new LWP::ConnCache;
- $lwp->conn_cache($conncache);
- my $file_log = "D:\\html.log";
- my $log = new FileHandle(">$file_log") || die "can not open $file_log\n";
- my $send_url = "http://www.simsimi.com/talk.htm";
- my %send_form = (
- "userinput" => "how are you",
- );
- #my $send_cookie = qq~ sessionhash=$sessionhash; PHPSESSID=$passid~;
- #print "Send_Cookie $send_cookie\n";
- $lwp->default_header('Cookie'=>'aaa');
- my $send_response = $lwp->post($send_url,\%send_form);
- if ($send_response->is_success) {
- my $html = $send_response->decoded_content;
- my $start = '<table class="new-templete">';
- my $end = '</table>';
- my @find_all = ($html =~ /$start(.*?)$end/gs);
- foreach(@find_all)
- {
- print $log $_;
- }
- if (encode('gbk',$html) =~ /发送成功/) {
- print "Data send sucessful!";
- }
- else { print "Data send failed!"; }
- }
- else {
- print "Data send error: ".$send_response->status_line;
- }
复制代码 记录到日志里边的内容是:
- <tr>
- <td class="bot">
- <div class="img-bot"></div>
- <div class="left-convo">Hi~!</div>
- </td>
- </tr>
-
复制代码 没有我想要的simsimi的回复,但是我在遨游的开发者工具中看到的html源码是有的:
请问我该怎样得到页面的全部源码呢? |
|