资讯专栏INFORMATION COLUMN

超赞!快来用Python的搭建你的AI老婆吧!

Tychio / 3253人阅读

摘要:夏天太热,又不想出门,就让我们用的来搭建属于自己的可以对话的老婆吧本文拟使用的开发语言实现类似于的平台的小娜,或者是下的的。

夏天太热,又不想出门,就让我们用的Python来搭建属于自己的〜可以对话的AI老婆吧〜

  本文拟使用Python的开发语言实现类似于的WIndows平台的“小娜”,或者是IOS下的“Siri的”。最终达到人机对话的效果。

【实现功能】

  柳猫将会从下面两个方面开始:

  1.搭建人工智能 - 人机对话服务端平台

  2.实现调用服务端平台进行人机对话交互

【实现思路】

  AIML

  AIML由Richard Wallace发明。他设计了一个名为ALICE(人工语言学互联网计算机实体人工语言网计算机实体)的机器人,并获得了多项人工智能大奖。有趣的是,图灵测试的其中一项就在寻找这样的人工智能:人与机器人通过文本界面展开数分钟的交流,以此查看机器人是否会被当作人类。

  本文就使用了Python的语言调用AIML库进行智能机器人的开发。

  本系统的运作方式是使用Python的搭建服务端后台接口,供各平台可以直接调用。然后客户端进行对智能对话API接口的调用,服务端分析参数数据,进行语句的分析,最终返回应答结果。

  当前系统前端使用HTML进行简单地聊天室的设计与编写,使用异步请求的方式渲染数据。

大家在学python的时候肯定会遇到很多难题,以及对于新技术的追求,这里推荐一下我们的Python学习扣qun:784,758,214,这里是python学习者聚集地

【开发及部署环境】

开发环境:Windows 7×64英文版

     JetBrains PyCharm 2017.1.3 x64

测试环境:Windows 7×64

【所需技术】

小伙伴们,如果要完全理解,请熟练以下技能(不会也​​没关系啦,一起学习就好了):

Python的语言的熟练掌握,Python的版本2.7及以上

Python的服务端开发框架龙卷风的使用

AIML库接口的简单使用

HTML + CSS +的JavaScript(jQuery的)的熟练使用

Ajax的技术的掌握

【实现过程】

  1.安装Python aiml库

pip install aiml

  2.获取alice资源

  Python aiml安装完成后在Python安装目录下的Lib / site-packages / aiml下会有alice子目录,将此目录复制到工作区。

或者在谷歌代码上下载

alice brain:aiml-en-us-foundation-alice.v1-9.zip

  3. Python下加载alice

  取得alice资源之后就可以直接利用Python aiml库加载alice brain了:

进口目的
os.chdir("./ src / alice")#将工作区目录切换到刚才复制的alice文件夹
alice = aiml.Kernel()
alice.learn( “startup.xml”)
alice.respond("LOAD ALICE")

  注意加载时需要切换工作目录到爱丽丝(刚才复制的文件夹)下。

  4.与alice聊天

  加载之后就可以与爱丽丝聊天了,每次只需要调用响应接口:

alice.respond("hello")#这里的hello即为发给机器人的信息

  柳猫紧接上篇,现在我们来实现AI老婆的对话(画脸):

  5.用Tornado搭建聊天机器人网站

  龙卷风可以很方便地搭建一个网络网站的服务端,并且接口风格是休闲风格,可以很方便搭建一个通用的服务端接口。

  这里写两个方法:

得到:渲染界面
岗位:获取请求参数,并分析,返回聊天结果

  类类的代码如下:

class ChatHandler(tornado.web.RequestHandler):
    def get(self):
        self.render( "chat.html")
    def post(self):
        尝试:
            message = self.get_argument("msg",None)
            打印(STR(消息))
            result = {
                "is_success":是的,
                "message":str(alice.respond(message))
            }
            打印(STR(结果))
            respon_json = tornado.escape.json_encode(结果)
            self.write(respon_json)
        除了例外,例如:
            再版(前)
            打印(STR(前))
            result = {
                "is_success":错,
                "信息": ""
            }
            self.write(STR(结果))

  6.简单搭建一个聊天界面

  该界面是基于自举的,我们简单搭建这么一个聊天的界面用于展示我们的接口结果。同时进行简单的聊天。

  7.接口调用

  我们异步请求服务端接口,并将结果渲染到界面

$就({
                    类型:"post",
                    url:AppDomain +"chat",
                    async:true,//异步
                    dataType:"json",
                    数据:(
                    {
                        “味精”:request_txt
                    }),
                    成功:功能(数据)
                    {
                        的console.log(JSON.stringify(数据));
                        if(data.is_success == true){
                            的setView(resUser,data.message);
                        }
                    },
                    错误:功能(数据)
                    {
                        的console.log(JSON.stringify(数据));
                    }
                }); //结束Ajax

  这里我附上系统的完整目录结构以及完整代码 - >

  8.目录结构

  9. Python服务端代码

#!/ usr / bin / env python
# -  *  - 编码:utf-8  -  *  - 
import os.path
导入tornado.auth
导入tornado.escape
import tornado.httpserver
import tornado.ioloop
导入tornado.options
import tornado.web
来自tornado.options导入定义,选项
进口口
进口目的
os.chdir( "./ SRC /爱丽丝")
alice = aiml.Kernel()
alice.learn( “startup.xml”)
alice.respond("LOAD ALICE")
define("port",default = 3999,help ="在给定端口上运行",type = int)
class Application(tornado.web.Application):
    def __init __(self):
        处理程序= [
            (r"/",MainHandler),
            (r"/ chat",ChatHandler),
        ]
        settings = dict(
            template_path = os.path.join(os.path.dirname(__ file __),"templates"),
            static_path = os.path.join(os.path.dirname(__ file __),"static"),
            调试=真,
        )
        #conn = pymongo.Connection("localhost",12345)
        #self.db = conn ["demo"]
        tornado.web.Application .__ init __(自我,处理程序,**设置)
class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.render( "的index.html")
    def post(self):
        result = {
            "is_success":是的,
            "message":"123"
        }
        respon_json = tornado.escape.json_encode(结果)
        self.write(STR(respon_json))
    def put(self):
        respon_json = tornado.escape.json_encode(“{"name":"qixiao","age":123}”)
        self.write(respon_json)
class ChatHandler(tornado.web.RequestHandler):
    def get(self):
        self.render( "chat.html")
    def post(self):
        尝试:
            message = self.get_argument("msg",None)
            打印(STR(消息))
            result = {
                "is_success":是的,
                "message":str(alice.respond(message))
            }
            打印(STR(结果))
            respon_json = tornado.escape.json_encode(结果)
            self.write(respon_json)
        除了例外,例如:
            再版(前)
            打印(STR(前))
            result = {
                "is_success":错,
                "信息": ""
            }
            self.write(STR(结果))
def main():
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance()。开始()
如果__name__ =="__ main__":
    print("HTTP服务器启动...")
    主要()

  10. Html前端代码

<!DOCTYPE html>


      
     qixiao tools </ title>
    <link rel =“stylesheet”type =“text / css”href =“../ static / css / bootstrap.min.css”>
    <script type =“text / javascript”src =“../ static / js / jquery-3.2.0.min.js”> </ script>
    <script type =“text / javascript”src =“../ static / js / bootstrap.min.js”> </ script>
    <style type =“text / css”>
        .TOP利润率-20 {
            margin-top:20px;
        }
        #result_table,#result_table thead th {
            text-align:center;
        }
        #result_table .td-width-40 {
            宽度:40%;
        }
    </样式>
    <script type =“text / javascript”>
    </ SCRIPT>
    <script type =“text / javascript”>
        var AppDomain ="http:// localhost:3999 /"
        $(文件)。就绪(函数(){
            $( “#btn_sub”)。点击(函数(){
                var user ="qixiao(10011)";
                var resUser ="alice(3333)";
                var request_txt = $(“#txt_sub”)。val();
                的setView(用户,request_txt);
                $就({
                    类型:"post",
                    url:AppDomain +"chat",
                    async:true,//异步
                    dataType:"json",
                    数据:(
                    {
                        “味精”:request_txt
                    }),
                    成功:功能(数据)
                    {
                        的console.log(JSON.stringify(数据));
                        if(data.is_success == true){
                            的setView(resUser,data.message);
                        }
                    },
                    错误:功能(数据)
                    {
                        的console.log(JSON.stringify(数据));
                    }
                }); //结束Ajax
                
            });
        });
        函数setView(用户,文本)
        {
            var subTxt = user +“”+ new Date()。toLocaleTimeString()+" n·"+ text;
            $( “#txt_view”)VAL($( “#txt_view”)VAL()+ " n  n" + subTxt。)。
            var scrollTop = $(“#txt_view”)[0] .scrollHeight;  
            $( “#txt_view”)scrollTop的(scrollTop的)。  
        }
    </ SCRIPT>
</ HEAD>
<body class =“container”>
    <header class =“row”>
        <header class =“row”>
            <a href="/" class="col-md-2" style="font-family:SimHei;font-size:20px;text-align:center;margin-top:30px;">
                <span class =“glyphicon glyphicon-home”> </ span>主页
            </A>
            <font class =“col-md-4 col-md-offset-2”style =“font-family:SimHei; font-size:30px; text-align:center; margin-top:30px;”>
                <a href="/tools" style="cursor: pointer;">奇晓 - 聊天</a>
            </ FONT>
        </报头>
        <HR>
        <article class =“row”>
            <section class =“col-md-10 col-md-offset-1”style =“border:border:solid#4B5288 1px; padding:0”>管理员:QiXiao </ section>
            <section class =“col-md-10 col-md-offset-1 row”style =“border:solid#4B5288 1px; padding:0”>
                <section class =“col-md-9”style =“height:400px;”>
                    <section class =“row”style =“height:270px;”>
                        <textarea class =“form-control”style =“width:100%; height:100%; resize:none; overflow-x:none; overflow-y:scroll;” readonly =“true”id =“txt_view”> </ textarea>
                    </节>
                    <section class =“row”style =“height:130px; border-top:solid#4B5288 1px;”>
                        <textarea class =“form-control”style =“overflow-y:scroll; overflow-x:none; resize:none; width:100%; height:70%; border:#fff”id =“txt_sub”> < / textarea>的
                        <button class =“btn btn-primary”style =“float:right; margin:0 5px 0 0”id =“btn_sub”>提交</ button>
                    </节>
                </节>
                <section class =“col-md-3”style =“height:400px; border-left:solid#4B5288 1px;”> </ section>
            </节>
        </文章>
    </ BODY>
    </ HTML>
</pre>
<p><strong>【系统测试】</strong></p>
<p>  <strong>1.首先我们将我们的服务运行起来</strong></p>
<p><script type="text/javascript">showImg("https://segmentfault.com/img/remote/1460000019437903");</script></p>
<p>  <strong>2.调用测试</strong></p>
<p>   然后我们进行前台界面的调用</p>
<p><script type="text/javascript">showImg("https://segmentfault.com/img/remote/1460000019437904");</script></p>
<p><script type="text/javascript">showImg("https://segmentfault.com/img/remote/1460000019437905");</script></p>
<p>  这里我们可以看到,我们的项目完美运行,并且达到预期效果。</p>           
               
                                           
                       
                 </div>
            
                     <div class="mt-64 tags-seach" >
                 <div class="tags-info">
                                                                                                                    
                         <a style="width:120px;" title="混合云" href="https://www.ucloud.cn/site/product/uhybrid.html">混合云</a>
                                             
                         <a style="width:120px;" title="私有云" href="https://www.ucloud.cn/site/product/ucloudstack.html">私有云</a>
                                                                                                                                                 
                                      
                     
                    
                                                                                               <a style="width:120px;" title="提高你的python" href="https://www.ucloud.cn/yun/tag/tigaonidepython/">提高你的python</a>
                                                                                                           <a style="width:120px;" title="你的看法" href="https://www.ucloud.cn/yun/tag/nidekanfa/">你的看法</a>
                                                                                                           <a style="width:120px;" title="你的电脑" href="https://www.ucloud.cn/yun/tag/nidediannao/">你的电脑</a>
                                                                                                           <a style="width:120px;" title="java你的名字" href="https://www.ucloud.cn/yun/tag/javanidemingzi/">java你的名字</a>
                                                         
                 </div>
               
              </div>
             
               <div class="entry-copyright mb-30">
                   <p class="mb-15"> 文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。</p>
                 
                   <p>转载请注明本文地址:https://www.ucloud.cn/yun/43998.html</p>
               </div>
                      
               <ul class="pre-next-page">
                 
                                  <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/43997.html">上一篇:关于Python编码这一篇文章就够了</a></li>  
                                                
                                       <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/43999.html">下一篇:用Python写了个检测文章抄袭,详谈去重算法原理</a></li>
                                  </ul>
              </div>
              <div class="about_topicone-mid">
                <h3 class="top-com-title mb-0"><span data-id="0">相关文章</span></h3>
                <ul class="com_white-left-mid atricle-list-box">
                             
                                                                                                    <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/41396.html"><b>「码个蛋」2017年200篇精选干货集合</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:让你收获满满码个蛋从年月日推送第篇文章一年过去了已累积推文近篇文章,本文为年度精选,共计篇,按照类别整理便于读者主题阅读。本篇文章是今年的最后一篇技术文章,为了让大家在家也能好好学习,特此花了几个小时整理了这些文章。

showImg(https://segmentfault.com/img/remote/1460000013241596);
让你收获满满!
码个蛋从2017年02月20...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-922.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/09/small_000000922.jpg" alt=""><span class="layui-hide64">wangtdgoodluck</span></a>
                                    <time datetime="">2019-07-30 15:40</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/37809.html"><b>蠎周刊 2015 年度最赞</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:蠎周刊年度最赞亲俺们又来回顾又一个伟大的年份儿包去年最受欢迎的文章和项目如果你错过了几期就这一期不会丢失最好的嗯哼还为你和你的准备了一批纪念裇从这儿获取任何时候如果想分享好物给大家在这儿提交喜欢我们收集的任何意见建议通过来吧原文

Title: 蠎周刊 2015 年度最赞Date: 2016-01-09 Tags: Weekly,Pycoder,Zh Slug: issue-198-to...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-76.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/00/small_000000076.jpg" alt=""><span class="layui-hide64">young.li</span></a>
                                    <time datetime="">2019-07-24 18:32</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/119774.html"><b>爆肝一周,用<em>Python</em>在物联网设备上写了个智能语音助手</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:背景介绍智能语音助手作为物联网领域的一个重要生态成员,是一种全新的交互方式,它能够解放双手,随时提供服务,无须借助任何按键。学完该案例让你对智能语音助手有一个全新的认识。快来打造你的智能语音助手吧                                                     1. 背景介绍 智能语音助手作为物联网领域的一个重要生态成员,是一种全新的交互方式,它能够解...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-1216.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/12/small_000001216.jpg" alt=""><span class="layui-hide64">I_Am</span></a>
                                    <time datetime="">2021-09-10 10:50</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/17945.html"><b>想玩转分布式存储引擎?<em>快来</em>加入 TiKV 团队<em>吧</em> | PingCAP 招聘季</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:负责构建分布式压力测试框架,稳定性测试框架。但同时,这些独立的模块最终会形成这一个整体。分布式一致性算法,现在无非就是两类,和,我们选择了。对各个模块进行详细的测试,使用等对系统进行注入测试。设计并实现性能回归测试平台。

上周我们推送了 TiDB 团队职位解读文章,当天就有很多简历砸来,我们深深感受到了小伙伴们的热情~ 趁热打铁,今天我司首席架构师唐刘老师将带大家了解一下传说中「面试通...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-239.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/02/small_000000239.jpg" alt=""><span class="layui-hide64">susheng</span></a>
                                    <time datetime="">2019-06-25 19:08</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                           
                </ul>
              </div>
              
               <div class="topicone-box-wangeditor">
                  
                  <h3 class="top-com-title mb-64"><span>发表评论</span></h3>
                   <div class="xcp-publish-main flex_box_zd">
                                      
                      <div class="unlogin-pinglun-box">
                        <a href="javascript:login()" class="grad">登陆后可评论</a>
                      </div>                   </div>
               </div>
              <div class="site-box-content">
                <div class="site-content-title">
                  <h3 class="top-com-title mb-64"><span>0条评论</span></h3>   
                </div> 
                      <div class="pages"></ul></div>
              </div>
           </div>
           <div class="layui-col-md4 layui-col-lg3 com_white-right site-wrap-right">
              <div class=""> 
                <div class="com_layuiright-box user-msgbox">
                    <a href="https://www.ucloud.cn/yun/u-563.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/05/small_000000563.jpg" alt=""></a>
                    <h3><a href="https://www.ucloud.cn/yun/u-563.html" rel="nofollow">Tychio</a></h3>
                    <h6>男<span>|</span>高级讲师</h6>
                    <div class="flex_box_zd user-msgbox-atten">
                     
                                                                      <a href="javascript:attentto_user(563)" id="attenttouser_563" class="grad follow-btn notfollow attention">我要关注</a>
      
                                                                                        <a href="javascript:login()" title="发私信" >我要私信</a>
                     
                                            
                    </div>
                    <div class="user-msgbox-list flex_box_zd">
                          <h3 class="hpf">TA的文章</h3>
                          <a href="https://www.ucloud.cn/yun/ut-563.html" class="box_hxjz">阅读更多</a>
                    </div>
                      <ul class="user-msgbox-ul">
                                                  <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/116271.html">前端面试每日3+1——第120天</a></h3>
                            <p>阅读 1368<span>·</span>2019-08-30 15:44</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/115783.html">对height 100%和inherit的总结</a></h3>
                            <p>阅读 1810<span>·</span>2019-08-30 14:07</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/115648.html">边距重叠以及解决方案BFC</a></h3>
                            <p>阅读 2761<span>·</span>2019-08-30 13:56</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/114108.html">译-使用Scroll Snapping实现CSS控制页面滚动</a></h3>
                            <p>阅读 2211<span>·</span>2019-08-29 17:06</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/113002.html">vertical-align,今晚来我房间聊聊剧本</a></h3>
                            <p>阅读 1119<span>·</span>2019-08-29 14:13</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/111672.html">小程序的开发成本真的比原生App低吗?</a></h3>
                            <p>阅读 1959<span>·</span>2019-08-29 11:28</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/109849.html">数组分割算法(JavaScript)</a></h3>
                            <p>阅读 3105<span>·</span>2019-08-26 13:56</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/108173.html">JavaScript学习第七天笔记(面向对象)</a></h3>
                            <p>阅读 1833<span>·</span>2019-08-26 12:11</p></li>
                                                
                      </ul>
                </div>

                   <!-- 文章详情右侧广告-->
              
  <div class="com_layuiright-box">
                  <h6 class="top-com-title"><span>最新活动</span></h6> 
           
         <div class="com_adbox">
                    <div class="layui-carousel" id="right-item">
                      <div carousel-item>
                                                                                                                       <div>
                          <a href="https://www.ucloud.cn/site/product/uhost.html"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/220620/Z7TLrpAi.png" alt="云服务器">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/product/uhybrid.html"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/220620/MWraMsBh.png" alt="混合云">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/product/ucloudstack.html"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/220620/ifzOxvjW.png" alt="私有云">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/product/utrion.html"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/220620/VDqwC1iN.png" alt="超融合服务器">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/product/uhybrid.html"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/220630/pJwnviKN.png" alt="服务器托管">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/product/uxzone.html"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/220630/CDb5uXxp.jpeg" alt="idc机房托管">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/active/network.html?ytag=seo"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/230227/XWsSXmvm.png" alt="专线服务">                                 
                          </a>
                        </div>
                                                                   
                    
                        
                      </div>
                    </div>
                      
                    </div>                    <!-- banner结束 -->
              
<div class="adhtml">

</div>
                <script>
                $(function(){
                    $.ajax({
                        type: "GET",
                                url:"https://www.ucloud.cn/yun/ad/getad/1.html",
                                cache: false,
                                success: function(text){
                                  $(".adhtml").html(text);
                                }
                        });
                    })
                </script>                </div>              </div>
           </div>
        </div>
      </div> 
    </section>
    <!-- wap拉出按钮 -->
     <div class="site-tree-mobile layui-hide">
      <i class="layui-icon layui-icon-spread-left"></i>
    </div>
    <!-- wap遮罩层 -->
    <div class="site-mobile-shade"></div>
    
       <!--付费阅读 -->
       <div id="payread">
         <div class="layui-form-item">阅读需要支付1元查看</div>  
         <div class="layui-form-item"><button class="btn-right">支付并查看</button></div>     
       </div>
      <script>
      var prei=0;

       
       $(".site-seo-depict pre").each(function(){
          var html=$(this).html().replace("<code>","").replace("</code>","").replace('<code class="javascript hljs" codemark="1">','');
          $(this).attr('data-clipboard-text',html).attr("id","pre"+prei);
          $(this).html("").append("<code>"+html+"</code>");
         prei++;
       })
           $(".site-seo-depict img").each(function(){
             
            if($(this).attr("src").indexOf('data:image/svg+xml')!= -1){
                $(this).remove();
            }
       })
     $("LINK[href*='style-49037e4d27.css']").remove();
       $("LINK[href*='markdown_views-d7a94ec6ab.css']").remove();
layui.use(['jquery', 'layer','code'], function(){
  $("pre").attr("class","layui-code");
      $("pre").attr("lay-title","");
       $("pre").attr("lay-skin","");
  layui.code(); 
       $(".layui-code-h3 a").attr("class","copycode").html("复制代码 ").attr("onclick","copycode(this)");
      
});
function copycode(target){
    var id=$(target).parent().parent().attr("id");
  
                  var clipboard = new ClipboardJS("#"+id);

clipboard.on('success', function(e) {


    e.clearSelection();
    alert("复制成功")
});

clipboard.on('error', function(e) {
    alert("复制失败")
});
}
//$(".site-seo-depict").html($(".site-seo-depict").html().slice(0, -5));
</script>
  <link rel="stylesheet" type="text/css" href="https://www.ucloud.cn/yun/static/js/neweditor/code/styles/tomorrow-night-eighties.css">
    <script src="https://www.ucloud.cn/yun/static/js/neweditor/code/highlight.pack.js" type="text/javascript"></script>
    <script src="https://www.ucloud.cn/yun/static/js/clipboard.js"></script>

<script>hljs.initHighlightingOnLoad();</script>

<script>
    function setcode(){
        var _html='';
    	  document.querySelectorAll('pre code').forEach((block) => {
        	  var _tmptext=$.trim($(block).text());
        	  if(_tmptext!=''){
        		  _html=_html+_tmptext;
        		  console.log(_html);
        	  }
    		 
    		  
    		 
      	  });
    	 

    }

</script>

<script>
function payread(){
  layer.open({
      type: 1,
      title:"付费阅读",
      shadeClose: true,
      content: $('#payread')
    });
}
// 举报
function jupao_tip(){
  layer.open({
      type: 1,
      title:false,
      shadeClose: true,
      content: $('#jubao')
    });

}
$(".getcommentlist").click(function(){
var _id=$(this).attr("dataid");
var _tid=$(this).attr("datatid");
$("#articlecommentlist"+_id).toggleClass("hide");
var flag=$("#articlecommentlist"+_id).attr("dataflag");
if(flag==1){
flag=0;
}else{
flag=1;
//加载评论
loadarticlecommentlist(_id,_tid);
}
$("#articlecommentlist"+_id).attr("dataflag",flag);

})
$(".add-comment-btn").click(function(){
var _id=$(this).attr("dataid");
$(".formcomment"+_id).toggleClass("hide");
})
$(".btn-sendartcomment").click(function(){
var _aid=$(this).attr("dataid");
var _tid=$(this).attr("datatid");
var _content=$.trim($(".commenttext"+_aid).val());
if(_content==''){
alert("评论内容不能为空");
return false;
}
var touid=$("#btnsendcomment"+_aid).attr("touid");
if(touid==null){
touid=0;
}
addarticlecomment(_tid,_aid,_content,touid);
})
 $(".button_agree").click(function(){
 var supportobj = $(this);
         var tid = $(this).attr("id");
         $.ajax({
         type: "GET",
                 url:"https://www.ucloud.cn/yun/index.php?topic/ajaxhassupport/" + tid,
                 cache: false,
                 success: function(hassupport){
                 if (hassupport != '1'){






                         $.ajax({
                         type: "GET",
                                 cache:false,
                                 url: "https://www.ucloud.cn/yun/index.php?topic/ajaxaddsupport/" + tid,
                                 success: function(comments) {

                                 supportobj.find("span").html(comments+"人赞");
                                 }
                         });
                 }else{
                	 alert("您已经赞过");
                 }
                 }
         });
 });
 function attenquestion(_tid,_rs){
    	$.ajax({
    //提交数据的类型 POST GET
    type:"POST",
    //提交的网址
    url:"https://www.ucloud.cn/yun/favorite/topicadd.html",
    //提交的数据
    data:{tid:_tid,rs:_rs},
    //返回数据的格式
    datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
    //在请求之前调用的函数
    beforeSend:function(){},
    //成功返回之后调用的函数
    success:function(data){
    	var data=eval("("+data+")");
    	console.log(data)
       if(data.code==2000){
    	layer.msg(data.msg,function(){
    	  if(data.rs==1){
    	      //取消收藏
    	      $(".layui-layer-tips").attr("data-tips","收藏文章");
    	      $(".layui-layer-tips").html('<i class="fa fa-heart-o"></i>');
    	  }
    	   if(data.rs==0){
    	      //收藏成功
    	      $(".layui-layer-tips").attr("data-tips","已收藏文章");
    	      $(".layui-layer-tips").html('<i class="fa fa-heart"></i>')
    	  }
    	})
    	 
       }else{
    	layer.msg(data.msg)
       }


    }   ,
    //调用执行后调用的函数
    complete: function(XMLHttpRequest, textStatus){
     	postadopt=true;
    },
    //调用出错执行的函数
    error: function(){
        //请求出错处理
    	postadopt=false;
    }
 });
}
</script>
<footer>
        <div class="layui-container">
            <div class="flex_box_zd">
              <div class="left-footer">
                    <h6><a href="https://www.ucloud.cn/"><img src="https://www.ucloud.cn/yun/static/theme/ukd//images/logo.png" alt="UCloud (优刻得科技股份有限公司)"></a></h6>
                    <p>UCloud (优刻得科技股份有限公司)是中立、安全的云计算服务平台,坚持中立,不涉足客户业务领域。公司自主研发IaaS、PaaS、大数据流通平台、AI服务平台等一系列云计算产品,并深入了解互联网、传统企业在不同场景下的业务需求,提供公有云、混合云、私有云、专有云在内的综合性行业解决方案。</p>
              </div>
              <div class="right-footer layui-hidemd">
                  <ul class="flex_box_zd">
                      <li>
                        <h6>UCloud与云服务</h6>
                         <p><a href="https://www.ucloud.cn/site/about/intro/">公司介绍</a></p>
                         <p><a href="https://zhaopin.ucloud.cn/" >加入我们</a></p>
                         <p><a href="https://www.ucloud.cn/site/ucan/onlineclass/">UCan线上公开课</a></p>
                         <p><a href="https://www.ucloud.cn/site/solutions.html" >行业解决方案</a></p>                                                  <p><a href="https://www.ucloud.cn/site/pro-notice/">产品动态</a></p>
                      </li>
                      <li>
                        <h6>友情链接</h6>                                             <p><a href="https://www.compshare.cn/?ytag=seo">GPU算力平台</a></p>                                             <p><a href="https://www.ucloudstack.com/?ytag=seo">UCloud私有云</a></p>
                                             <p><a href="https://www.surfercloud.com/">SurferCloud</a></p>                                             <p><a href="https://www.uwin-link.com/">工厂仿真软件</a></p>                                             <p><a href="https://pinex.it/">Pinex</a></p>                                             <p><a href="https://www.picpik.ai/zh">AI绘画</a></p>
                                             
                      </li>
                      <li>
                        <h6>社区栏目</h6>
                         <p><a href="https://www.ucloud.cn/yun/column/index.html">专栏文章</a></p>
                     <p><a href="https://www.ucloud.cn/yun/udata/">专题地图</a></p>                      </li>
                      <li>
                        <h6>常见问题</h6>
                         <p><a href="https://www.ucloud.cn/site/ucsafe/notice.html" >安全中心</a></p>
                         <p><a href="https://www.ucloud.cn/site/about/news/recent/" >新闻动态</a></p>
                         <p><a href="https://www.ucloud.cn/site/about/news/report/">媒体动态</a></p>                                                  <p><a href="https://www.ucloud.cn/site/cases.html">客户案例</a></p>                                                
                         <p><a href="https://www.ucloud.cn/site/notice/">公告</a></p>
                      </li>
                      <li>
                          <span><img src="https://static.ucloud.cn/7a4b6983f4b94bcb97380adc5d073865.png" alt="优刻得"></span>
                          <p>扫扫了解更多</p></div>
            </div>
            <div class="copyright">Copyright © 2012-2023 UCloud 优刻得科技股份有限公司<i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/">沪公网安备 31011002000058号</a><i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/"></a> 沪ICP备12020087号-3</a><i>|</i> <script type="text/javascript" src="https://gyfk12.kuaishang.cn/bs/ks.j?cI=197688&fI=125915" charset="utf-8"></script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?290c2650b305fc9fff0dbdcafe48b59d";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DZSMXQ3P9N"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-DZSMXQ3P9N');
</script>
<script>
(function(){
var el = document.createElement("script");
el.src = "https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?99f50ea166557aed914eb4a66a7a70a4709cbb98a54ecb576877d99556fb4bfc3d72cd14f8a76432df3935ab77ec54f830517b3cb210f7fd334f50ccb772134a";
el.id = "ttzz";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(el, s);
})(window)
</script></div> 
        </div>
    </footer>
</body>
<script src="https://www.ucloud.cn/yun/static/theme/ukd/js/common.js"></script>
<<script type="text/javascript">
$(".site-seo-depict *,.site-content-answer-body *,.site-body-depict *").css("max-width","100%");
</script>
</html>