LUA代码:(注:LUA里有一个调用百度识图的接口IP:123.125.115.189(stu.baidu.com),不知为什么我的虚拟机无法解析stu.baidu.com,所以我只能PING出IP来用。)

location /test {
content_by_lua ' local request_method = ngx.var.request_method;
local args = nil;
if "GET" == request_method then
args = ngx.req.get_uri_args();
else
ngx.req.read_body();
args = ngx.req.get_post_args();
end local imageUrl = args["imageUrl"] function Split(szFullString, szSeparator)
local nFindStartIndex =
local nSplitIndex =
local nSplitArray = {}
while true do
local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)
if not nFindLastIndex then
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))
break
end
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - )
nFindStartIndex = nFindLastIndex + string.len(szSeparator)
nSplitIndex = nSplitIndex +
end
return nSplitArray
end local cjson = require "cjson"
local http = require "resty.http"
local hc = http:new() local ok, code, headers, status, body = hc:request {
url = "http://123.125.115.189/n/pc_search?queryImageUrl="..imageUrl,
method = "GET", -- POST or GET
} local _,aaa = string.find(body,"keywords:\'")
local bbb = string.find(body,"|default")
local ccc = string.sub(body,aaa+,bbb-)
ngx.say(tostring(ccc))
';
}

HTML代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled</title>
<script src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
</head> <body> <input type="button" value = "test" id ="test" />
<input type="text" id ="imgUrl" />
<input type="button" value = "识图" id ="st" /> </body> <script> function unicode2Chr(str) {
str=str.replace(/\\/g,"%");
return unescape(str); } $(function(){
$("#test").click(function(){
alert();
var str = "\x22\\u82f9\\u679c\x22,\x22\\u6307\\u6325\\u5927\\u5e08\x22,\x22\\u51fa\\u67dc\x22";
var code = str.replace(/\x22/g, "")
alert(code);
alert(unicode2Chr(code));
}); $("#st").click(function(){ var image_Url = $("#imgUrl").val(); $.ajax({
type : "POSST",
async : false,
url : "/test",
data:{imageUrl:image_Url},
success : function(data) {
var code = data.replace(/\\x22/g, "")
alert(unicode2Chr(code).replace(/%/g, ""));
}
});
}); }); </script>
</html>

OpenResy+Lua 利用百度识图 将图片地址解析成文字的更多相关文章

  1. 安卓开发 利用百度识图api进行物体识别

    前文 之前的随笔中,已经通过相机或相册获取到了我们想要的图片,接下来进行识图api的配置工作.我使用的是百度的api,利用python获取信息,并在MainActivity中进行调用来输出信息. 一. ...

  2. 安卓开发 利用百度识图api进行物体识别(java版)

    之前的随笔中,已经实现了python版本调用api接口,之所以使用python是因为python比java要简洁. 但是我发现在使用过程中,chaquopy插件会弹出底部toast显示"un ...

  3. 利用百度AI OCR图片识别,Java实现PDF中的图片转换成文字

    序言:我们在读一些PDF版书籍的时候,如果PDF中不是图片,做起读书笔记的还好:如果PDF中的是图片的话,根本无法编辑,做起笔记来,还是很痛苦的.我是遇到过了.我们搞技术的,当然得自己学着解决现在的痛 ...

  4. 通过AI识图判断图片是否为小票

    先在百度智能云中创建一个应用加入以下标记功能(没有智能云账号可以去创建一个,创建应用也都是些基本操作) 本次只用到标记的功能. 此功能在图像识别下面. 创建应用后,页面会出现平台分配的密钥:API K ...

  5. 百度识图for windows phone 上线

    原文发布时间为:2013-07-04 -- 来源于本人的百度文章 [由搬家工具导入] 百度识图主要用于找女神,找男神,找美图,找宠物,找图文新闻,找相似图,找原图,还能鉴别头像照片真伪,免得被网络照片 ...

  6. 百度识图API

    http://stu.baidu.com/ http://www.360doc.com/content/14/0801/17/21412_398653199.shtml http://download ...

  7. 阿里云OCR图片转换成文字识别调用

    using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Drawing; using S ...

  8. PHP图片识别成文字

    http://apistore.baidu.com/apiworks/servicedetail/146.html 分类: php2011-- : 3576人阅读 评论() 收藏 举报 phpfunc ...

  9. python3 自动识图

    一.安装依赖库 pip install pytesseract pip install pillow 二.安装识图引擎tesseract-ocr https://pan.baidu.com/s/1Qa ...

随机推荐

  1. C#学习笔记----栈与堆的知识

    http://my.oschina.net/lichaoqiang/blog/291906 当我们对.NET Framework的一些基本面了解之后,实际上,还是很有必要了解一些更底层的知识.比如.N ...

  2. Oracle如何写出高效的SQL

    转载:http://www.blogjava.net/ashutc/archive/2009/07/19/277215.html 1.选择最有效率的表明顺序(只在基于规则的优化器中有效) Oracle ...

  3. bootstrap组件 2

    bootstrap组件2 <!DOCTYPE html> <html lang="zh-cn"> <head > <meta charse ...

  4. 手机web页面制作时的注意事项

    一.手机页面的标准头规范 字符编码使用utf-:指定页面手机内存缓存中的存储时间段 device-width:通知浏览器使用设备的宽度作为可视区的宽度 initial-scale - 初始的缩放比例 ...

  5. PMP 第十三章 项目干系人管理

    1.识别干系人是干什么?早期就识别干系人的原因是什么?识别干系人的输入和工具有哪些?干系人分析的几种模型是哪些?干系人登记册的内容有哪些?bbs.mypm.net 2.干系人参与程度的分类是怎样的?干 ...

  6. C# jsonhelper

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Sc ...

  7. PHP 部署发布接口

    环境前提:电脑已安装wamp ① 在\wamp\bin\apache\apache2.4.9\conf\httpd.conf文件中, 修改 DocumentRoot 为当前项目路径,例如 Docume ...

  8. mageView图片显示出来 ()

    ImageView图片显示出来: igSign 是 ImageView的实例 igSign.setImageDrawable(getResources().getDrawable(R.drawable ...

  9. 解决Android解析图片的OOM问题!!!(转)

    大家好,今天给大家分享的是解决解析图片的出现oom的问题,我们可以用BitmapFactory这里的各种Decode方法,如果图片很小的话,不会出现oom,但是当图片很大的时候 就要用BitmapFa ...

  10. ubuntu中jdk已经安装,但是eclipse启动报错

    问题描述 在ubuntu中,jdk已经正常安装,java_home变量已经配置,但是启动eclipse的时候还是弹出以下错误信息: A Java RunTime Environment (JRE) o ...