- 论坛徽章:
- 0
|
simsimi聊天机器人,可以实现自动聊天。上图
我在页面上右键查看源码,并不能看到我发的“你好”和simsimi回的“不要啦”这两句的东西。只有打开这个页面simsimi默认发出的Hi~~~这一句:- <div id="msgs">
- <table class="new-templete">
- <tr>
- <td class="bot">
- <div class="img-bot"></div>
- <div class="left-convo">Hi~!</div>
- </td>
- </tr>
- </table>
- </div>
复制代码 但是如果使用开发者工具就能找到我发的“你好”和simsimi回的“不要啦”这两句的代码:
不知道这两种查看方法为什么不一样?我是想用perl程序取出simsimi给我的回复来实现一个简单的聊天软件。
上传我的代码:- #!/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;
- }
复制代码 程序中的$html变量是没有我发的“你好”和simsimi回的“不要啦”这两句的。请高手指点一二,谢谢! |
|