首页
时事
归档
壁纸
更多
留言
关于
邻里
Search
1
使用必应Bing每日图片做网站背景(自动)
2,810 阅读
2
vue的输入值校验规则整理
1,443 阅读
3
好站推荐-https://wangchujiang.com/linux-command/
1,391 阅读
4
微信支付开发前准备(小程序、公众号、App、H5)
1,391 阅读
5
VUE `ERR_CONNECTION_TIMED_OUT`的解决办法
1,321 阅读
文章
图说
代码
吐槽
登录
Search
标签搜索
Linux
laravel
windows
TYPO3
php
shell脚本
git
微信
好站
vue
第三方登录
centos
linxu
centos7
thinkPHP
微信支付
api
MySQL
桌面
必应首图
Beer
累计撰写
114
篇文章
累计收到
21
条评论
首页
栏目
文章
图说
代码
吐槽
页面
时事
归档
壁纸
留言
关于
邻里
搜索到
59
篇与
代码
的结果
2019-03-04
typecho中添加HTML代码压缩功能
为什么要压缩HTML主要是把 HTML 代码格式化为当行,去除回车注释等无效字符串以增加网页传速效率. Nginx , Apache 有类似的模块可以直接输出类似的单行 HTML ps:摘自网络代码需要修改两个地方,function.php,footer.php,处理方法放在function.php文件中,方便全局调用,/** * 压缩HTML代码 * * @param [type] $html_source * @return void * @author wanghongbin * @email info@whongbin.cn */ function compressHtml($html_source) { $chunks = preg_split('/(<!--<nocompress>-->.*?<!--<\/nocompress>-->|<nocompress>.*?<\/nocompress>|<pre.*?\/pre>|<textarea.*?\/textarea>|<script.*?\/script>)/msi', $html_source, -1, PREG_SPLIT_DELIM_CAPTURE); $compress = ''; foreach ($chunks as $c) { if (strtolower(substr($c, 0, 19)) == '<!--<nocompress>-->') { $c = substr($c, 19, strlen($c) - 19 - 20); $compress .= $c; continue; } else if (strtolower(substr($c, 0, 12)) == '<nocompress>') { $c = substr($c, 12, strlen($c) - 12 - 13); $compress .= $c; continue; } else if (strtolower(substr($c, 0, 4)) == '<pre' || strtolower(substr($c, 0, 9)) == '<textarea') { $compress .= $c; continue; } else if (strtolower(substr($c, 0, 7)) == '<script' && strpos($c, '//') != false && (strpos($c, "\r") !== false || strpos($c, "\n") !== false)) { $tmps = preg_split('/(\r|\n)/ms', $c, -1, PREG_SPLIT_NO_EMPTY); $c = ''; foreach ($tmps as $tmp) { if (strpos($tmp, '//') !== false) { if (substr(trim($tmp), 0, 2) == '//') { continue; } $chars = preg_split('//', $tmp, -1, PREG_SPLIT_NO_EMPTY); $is_quot = $is_apos = false; foreach ($chars as $key => $char) { if ($char == '"' && $chars[$key - 1] != '\\' && !$is_apos) { $is_quot = !$is_quot; } else if ($char == '\'' && $chars[$key - 1] != '\\' && !$is_quot) { $is_apos = !$is_apos; } else if ($char == '/' && $chars[$key + 1] == '/' && !$is_quot && !$is_apos) { $tmp = substr($tmp, 0, $key); break; } } } $c .= $tmp; } } $c = preg_replace('/[\\n\\r\\t]+/', ' ', $c); $c = preg_replace('/\\s{2,}/', ' ', $c); $c = preg_replace('/>\\s</', '> <', $c); $c = preg_replace('/\\/\\*.*?\\*\\//i', '', $c); $c = preg_replace('/<!--[^!]*-->/', '', $c); $compress .= $c; } return $compress; }调用方法放在footer.php文件中,实现效果 ps:放在html结束标签之后<?php $html_source = ob_get_contents(); ob_clean(); print compressHtml($html_source); ob_end_flush(); ?>兼容代码如果代码中有一些地方压缩后不被解析,出现不兼容问题,可以使用使用下面方法自行修改插件代码来保证这些不兼容的代码可以运行<!-- <nocompress > --> 不兼容代码 <!-- </nocompress > --> <nocompress > 不兼容代码 </nocompress >
2019年03月04日
548 阅读
0 评论
0 点赞
2019-02-27
自定义百度分享(样式,文件加载)
前言百度分享目前来说应该是用的比较多的第三方分享组件了,但是百度的默认样式又不是那么美观,遂在此分享下自定义修改百度分享样式的方法,支持https方法看这篇文章百度分享不支持Https的解决方案代码<head> <style> .bdsharebuttonbox.bdshare-button-style0-24 a {float: none;display: inline-block;margin: 0 2px;position: relative;} .bdsharebuttonbox.bdshare-button-style0-24 span {position: relative;vertical-align: top;} .bdsharebuttonbox.bdshare-button-style0-24 a.bds_more {color: #666;font-size: 14px;} </style> </head> <body> <div class="action-share"> <div class="bdsharebuttonbox bdshare-button-style0-24" data-bd-bind="1517296141901"> <span>分享到:</span> <a class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a> <a class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a> <a class="bds_weixin" data-cmd="weixin" title="分享到微信"></a> <a class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a> <a class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a> <a class="bds_bdhome" data-cmd="bdhome" title="分享到百度新首页"></a> <a class="bds_tqf" data-cmd="tqf" title="分享到腾讯朋友"></a> <a class="bds_youdao" data-cmd="youdao" title="分享到有道云笔记"></a> <a class="bds_more" data-cmd="more">更多</a> <span>(</span><a class="bds_count" data-cmd="count" title="累计分享0次">0</a><span>)</span> </div> <script> window._bd_share_config = { common: { "bdText" : "", "bdMini" : "2", "bdMiniList" : false, "bdPic" : "", "bdStyle" : "0", "bdSize" : "24" }, share: [{ bdCustomStyle: "./css/share.css" }] } with(document)0[(getElementsByTagName("head")[0]||body).appendChild(createElement("script")).src="http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion="+~(-new Date()/36e5)]; </script> </div> </body> </html>源码下载下载地址 链接:https://pan.baidu.com/s/1Yvtc84qQ7mQU_6GB-hxhOQ 密码:e9my
2019年02月27日
520 阅读
0 评论
0 点赞
2019-02-27
百度分享不支持Https的解决方案
前期工作static 解压后丢到站点的根目录,这里需要确保根目录能被访问到,即你的域名可访问目录,然后对应的百度分享代码中,把http://bdimg.share.baidu.com/改为/,就是说让系统自动去补全访问目录,前期工作就是这样了示例代码<!— 百度分享start —> <script> window._bd_share_config = { common: { "bdText" : "", "bdMini" : "2", "bdMiniList" : false, "bdPic" : "", "bdStyle" : "0", "bdSize" : "24" }, share: [{ bdCustomStyle: "/public/css/share.css" }] } with(document)0[(getElementsByTagName("head")[0]||body).appendChild(createElement("script")).src="/static/api/js/share.js?cdnversion="+~(-new Date()/36e5)]; </script> <!— 百度分享end —>下载地址文件原址:https://github.com/hrwhisper/baiduShare下载链接:https://pan.baidu.com/s/1TmyZ1DUAz6h1G0sf7Kw2PA 密码:gs17参考文档:https://www.hrwhisper.me/baidu-share-not-support-https-solution/
2019年02月27日
523 阅读
0 评论
0 点赞
2019-02-27
解决UEDITOR自动将DIV标签换成P标签的问题
前言在项目中使用UEditor时,发现编辑器会自动将HTML代码中的<div>标签替换为<p>标签,本来的样式都没了,可以说是贼鸡儿烦了,几经周折,终于找到了修改办法解决办法:在ueditor.all.js文件或ueditor.all.min.js内搜索allowDivTransToP,找到如下的代码,将true设置为falseme.setOpt({ //'allowDivTransToP':true, 'allowDivTransToP':false, 'disabledTableInTable':true });注:在ueditor.config.js文件内搜索一下allowDivTransToP,如果找到如下的代码,将注释去掉并且改为false//,allowDivTransToP:true //允许进入编辑器的div标签自动变成p标签 ,allowDivTransToP:false //允许进入编辑器的div标签自动变成p标签完成这样就把UEditor的<div>自动替换为<p>标签问题修改完成了,刷新js加载就能看到效果了
2019年02月27日
650 阅读
0 评论
0 点赞
2019-02-27
爬取必应首页大图 - Python
不废话,直接上代码# -*- coding: utf-8 -*- # @Author: Wang Hongbin # @Email: wanghongbin@ngoos.org # @Date: 2018-03-16 14:19:27 # @Last Modified by: Wang Hongbin # @Last Modified time: 2018-03-28 16:26:07 import requests import re import os import time #时间模块 local = time.strftime("%Y-%m-%d_") baseUrl = "https://cn.bing.com" headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36'} def getImgUrl(url): reg1 = r"(/az/hprichbg/rb/.*?.jpg)" con = requests.get(url) content = con.text imgUrl = re.findall(reg1, content, re.S)[0] # imgLink = baseUrl+imgUrl return imgUrl def getFilePath(): # filePath = '/var/www/html/biYinPic/images/' + time.strftime("%Y%m%d") + '/' filePath = 'C:/Users/Administrator/Pictures/MyDesktop/' if not os.path.exists(filePath): os.mkdir(filePath) return filePath def getImgName(url): reg2 = r"/az/hprichbg/rb/(.*?)_" imgName = re.findall(reg2, url, re.S)[0] imgName = local + imgName + '.jpg' return imgName def downloadByPic(url): imgUrl = getImgUrl(url) imgName = getImgName(imgUrl) filePath = getFilePath() fileName = filePath+imgName picUrl = baseUrl + imgUrl read = requests.get(picUrl) f = open(fileName, 'wb') f.write(read.content) f.close() # reg3 = r'<div class=\"hplaCata\"><div class=\"hplatt\">(.*)</div><div class=\"hplats\">(.*)</div><div id=\"hplaSnippet\">(.*)</div><div class=\"hplaPvd\">(.*)</div>' downloadByPic(baseUrl) print('is ok!')爬取结果下图是七月份至今的爬取图片,因为是在window上执行的,电脑不开机的时候不会执行,代码放在Linux上执行也没问题,使用crontab启个定时器就行了
2019年02月27日
573 阅读
0 评论
0 点赞
2019-02-27
爬取必应首页大图 - PHP
不废话,直接上代码<?php /** * 获取bing首页大图保存在本地 * @Author: Wang Hongbin * @Email: wanghongbin@ngoos.org * @Date: 2018-02-24 15:21:40 * @Last Modified by: Wang Hongbin * @Last Modified time: 2018-02-24 15:36:52 */ class GetBingPic { private $bingApiXml; private $bingApiJson; function __construct() { // 返回xml格式 $this->bingApiXml = "http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1"; // 返回json格式 $this->bingApiJson = "http://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1"; } /** * xml格式数据 * @return [type] [description] */ public function getDataXml() { $url = $this->bingApiXml; $data = $this->httpGet($url); return $data; } /** * json格式数据 * @return [type] [description] */ public function getDataXml() { $url = $this->bingApiJson; $data = $this->httpGet($url); return $data; } private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); return $res; } } $BingPic = new GetBingPic(); $xmldata = $BingPic->getDataXml(); var_dump($xmldata);爬取结果下图是七月份至今的爬取图片,因为是在window上执行的,电脑不开机的时候不会执行,代码放在Linux上执行也没问题,使用crontab启个定时器就行了啰嗦几句其实也没啥,就是还有python的版本 爬取必应首页大图 - Python
2019年02月27日
522 阅读
0 评论
0 点赞
2019-02-27
web网站接入GitHub第三方登录(踩坑)
web网站接入GitHub第三方登录(踩坑)博客已近上线了几个月了,但是一直没有做用户登录,这两天想了下,干脆直接用第三方登录吧,最终决定用QQ,Gitee,GitHub三种方式登录,下面是我的踩坑纪录和实现源码,分享出来官方文档地址https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/创建应用,获取Client ID,Client Secret,Authorization callback URL进入后,找到左侧 Developer settings填写你的应用信息,保存即可保存后,纪录下面的两个值和你填写的回调地址更新有朋友在使用下面代码的时候说报错了,然后我才发现我的文章内容没有写完整 [aru_85] ,惭愧,特在此表示歉意并且更新下本篇文章内容,保证尽量少的出现问题2018-10-18日更新在使用下面代码的时候,请先执行以下命令(对Windows无爱,仅Linux),#安装第三方类库 composer require sy-records/oauth-login安装完成后在控制器中引用use Auth\GithubConnect;编写代码,获取数据1. 入口重定向接口:https://github.com/login/oauth/authorize?client_id=yourclientid&redirect_uri=yourredirect_uri<a href="https://github.com/login/oauth/authorize?client_id=yourclientid&redirect_uri=yourredirect_uri">github登录</a>重定向至下面页面2. 根据code获取access_token回调页面中处理获取access_token接口:https://github.com/login/oauth/access_token// 用户登录 if (isset($_GET['code'])) { $access_token_url = 'https://github.com/login/oauth/access_token'; $params = array( 'client_id' => self::GITHUB_CLIENT_ID, 'client_secret' => self::GITHUB_CLIENT_SECRET, 'code' => $_GET['code'], ); $access_token = getHttpResponsePOST($access_token_url, $params); }取到的access_token数据格式是stringaccess_token=e72e16c7e42f292c6912e7710c838347ae178b4a&token_type=bearer3. 根据access_token获取用户信息获取用户信息接口:https://api.github.com/user在这我用的是curl进行http请求,if ($access_token) { $info_url = 'https://api.github.com/user?'.$access_token; $data = array(); parse_str($access_token,$data); $token = $data['access_token']; $url = "https://api.github.com/user?access_token=".$token; $headers[] = 'Authorization: token '.$token; $headers[] = "User-Agent: 木木彡博客"; $result = getHttpResponseGET($info_url,[],$headers); $info = json_decode($result,true); if (isset($info['id'])) { // 处理获取到的数据 } }4. 开发过程中的坑上面步骤中,第一步和第二步都没问题,但是到第三部时,看我代码你会发现,我在curl请求时添加了header,这个header必须填写,这可能是github的严格的验证机制吧,其中1、Authorization填写内容是你获取到的access_token,例:"Authorization: token e72e16c7e42f292c6912e7710c838347ae178b4a";2、User-Agent填写内容是你的应用名称,如我的应用名称是木木彡博客,例:"User-Agent: 木木彡博客"5. 处理数据完整代码// 用户登录 public function github() { if (isset($_GET['code'])) { $access_token_url = 'https://github.com/login/oauth/access_token'; $params = array( 'client_id' => self::GITHUB_CLIENT_ID, 'client_secret' => self::GITHUB_CLIENT_SECRET, 'code' => $_GET['code'], ); $access_token = getHttpResponsePOST($access_token_url, $params); if ($access_token) { $info_url = 'https://api.github.com/user?'.$access_token; $data = array(); parse_str($access_token,$data); $token = $data['access_token']; $url = "https://api.github.com/user?access_token=".$token; $headers[] = 'Authorization: token '.$token; $headers[] = "User-Agent: 木木彡博客"; $result = getHttpResponseGET($info_url, $headers); $info = json_decode($result,true); if (isset($info['id'])) { $Oauth = new OauthModel(); $num = $Oauth->github($info); if ($num==3) { // 登录成功 $this->redirect('index/index'); } } } } } /** * 远程获取数据,POST模式 * @param $url 指定URL完整路径地址 * @param $param 请求的数据 * return 远程输出的数据 */ function getHttpResponsePOST($url = '', $param = array()) { if (empty($url) || empty($param)) { return false; } $ch = curl_init();//初始化curl curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页 curl_setopt($ch, CURLOPT_HEADER, 0);//设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $param); $data = curl_exec($ch);//运行curl curl_close($ch); return $data; } /** * 远程获取数据,GET模式 * 注意: * @param $url 指定URL完整路径地址 * @param $header 头部 * return 远程输出的数据 */ function getHttpResponseGET($url,$header=null) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); if(!empty($header)){ curl_setopt($curl, CURLOPT_HTTPHEADER, $header); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); // echo curl_getinfo($curl); curl_close($curl); unset($curl); return $output; }
2019年02月27日
570 阅读
0 评论
0 点赞
2019-02-27
MySQL更新一个表字段的值到另一个表字段
MySQL更新一个表字段的值到另一个表字段有时在新建了一张数据表之后,需要做些测试,但是表中没有数据,可以使用下面方法更新数据库,达到测试目的同一张表中数据(当前表)update tableA A set A.actvalid=A.svalid where A.actvalid='0000-00-00 00:00:00';不同表中数据update tableA A,tableB B set A.typeA=B.typeB where A.idA=B.idB;
2019年02月27日
520 阅读
0 评论
0 点赞
2019-02-18
通过QQ号获取信息
通过QQ号获取信息以下代码直接新建PHP文件粘贴即可使用<?php /** * 通过QQ号获取用户信息 * 获取QQ头像接口:http://q1.qlogo.cn/g?b=qq&nk=QQ号&s=100&t=1547904810 * 获取QQ昵称接口:http://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?g_tk=1518561325&uins=QQ号 */ header('Content-Type: text/html;charset=utf-8'); $QQ=$_GET["qq"]; if($QQ!=''){ $urlPre='http://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?g_tk=1518561325&uins='; $data=file_get_contents($urlPre.$QQ); $data=iconv("GB2312","UTF-8",$data); $pattern = '/portraitCallBack\((.*)\)/is'; preg_match($pattern,$data,$result); $result=$result[1]; $nickname = json_decode($result, true)["$QQ"][6]; $headimg = "http://q1.qlogo.cn/g?b=qq&nk=$QQ&s=100&t=1547904810"; $email = $QQ."@qq.com"; exit(json_encode(['nickname'=>$nickname,'headimg'=>$headimg,'email'=>$email])); }else{ echo "请输入qq号!"; } ?>
2019年02月18日
940 阅读
0 评论
0 点赞
2019-02-14
使用必应Bing每日图片做网站背景(自动)
创建API文件在项目允许访问的目录下创建一个PHP文件供后续调用 api.php 调用地址:http://访问目录/api.phpAPI代码以下代码复制粘贴即可<?php //从bing获取数据 $str = file_get_contents('https://cn.bing.com/HPImageArchive.aspx?idx=0&n=1'); if (preg_match("/\<url\>(.+?)<\/url>/ies", $str, $matches)) { //正则匹配抓取图片url $imgurl = 'https://cn.bing.com' . $matches[1]; } else { //使用默认的图像 $imgurl = 'https: //picsum.photos/1920/1080/?random'; } header("Location: $imgurl"); ?>使用方法例:如果作为页面背景图的话,使用下面代码即可body{ width:100%; height:100%; background: url(API地址) no-repeat; -moz-background-size: cover; /*背景图片拉伸以铺满全屏*/ -ms-background-size: cover; -webkit-background-size: cover; background-size: cover; }
2019年02月14日
2,810 阅读
2 评论
0 点赞
2018-08-14
使用翔云 OCR 开发名片识别API数据保存到数据库
公司近几天一直再开发crm,在开发crm的时候,用户数据较多,仅靠表单提交和导入去录入数据完全不够,于是想到了开发名片扫描时别。。。 本次开发使用的是翔云ocr,为啥会用这个呢,我在找了一圈以后本来准备使用腾讯云的SDK进行开发,但是我写了一个demo后进行测试,发现腾讯云的SDK转化率并不像是管方文档着呢说的达到90%,能达到70%都是非常不错了,后来又找了找,发现翔云还不错,果断购买之!下面说下两种api的调用方式1、使用PHP进行调用不得不说,翔云的api示例还是有点小瑕疵的,下面已做修改<?php /** * 翔云OCR名片识别类 * @Date: 2018-08-14 10:11:38 * @Author: Wang HongBin | <whb199330@163.com> * @Last Modified by: Wang HongBin * @Last Modified time: 2018-08-14 10:16:19 */ class XiangYunOCR { /** * 获取名片信息 * @Author wanghongbin * @Email wanghongbin@ngoos.org * @DateTime 2018-08-14 * @param [type] $filepath [description] * @return [type] [description] */ public function cardInfo($filepath) { $ocr = $this->cardOCR ( $filepath ); if ($ocr) { if ($ocr ['message'] ['status'] == 0) { $cardinfo = $ocr ['cardsinfo'] [0]; foreach ( $cardinfo ['items'] as $k => $v ) { if ($v ['desc'] == "姓名") { $card ['name'] = $v ['content']; } if ($v ['desc'] == "职务/部门") { $card ['position'] = $v ['content']; } if ($v ['desc'] == "公司") { $card ['company'] = $v ['content']; } if ($v ['desc'] == "手机") { $card ['mobile'] [] = $v ['content']; } if ($v ['desc'] == "电话") { $card ['tel'] = $v ['content']; } if ($v ['desc'] == "传真") { $card ['fax'] = $v ['content']; } if ($v ['desc'] == "电子邮箱") { $card ['email'] = $v ['content']; } if ($v ['desc'] == "网址") { $card ['www'] = $v ['content']; } if ($v ['desc'] == "邮编") { $card ['postcode'] = $v ['content']; } } } } else { $card = $ocr; } return $card; } // 远程提交OCR获取数据 protected function cardOCR($filepath) { $filepath = realpath ( $filepath ); $file = array ( "key" => "*******************", "secret" => "*******************", "typeId" => "20",//20对应名片识别 "format" => "json", "file" => new \CURLFile ( $filepath, 'image/jpeg' ) ); $curl = curl_init (); curl_setopt ( $curl, CURLOPT_URL, "http://netocr.com/api/recog.do" ); curl_setopt ( $curl, CURLOPT_POST, true ); curl_setopt ( $curl, CURLOPT_POSTFIELDS, $file ); curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true ); $result = curl_exec ( $curl ); curl_close ( $curl ); return json_decode ( $result, true ); } }调用require_once('../XiangYunOCR.php'); $OCR = new XiangYunOCR(); $ocr = $OCR->cardInfo ($filepath);使用html5调用<form id="uploadForm" name="uploadForm" action="" method="post" enctype="multipart/form-data" > <div id="img-view" onclick="document.getElementById('file').click();return false;"><i class="glyphicon glyphicon-plus" style="font-size: 30px;position: relative;top: 9px;right: 5px;"></i>点击选择图片或拍照</div> <input type="file" name="file" class="hide" id="file" onchange="view_img(this);"> <input type="hidden" name="format" value="json"> <input type="hidden" name="typeId" value="20"> <input type="hidden" name="key" value="yourkey" /> <input type="hidden" name="secret" value="yoursecret" /> <input type="hidden" name="_dontcare"> </form>//上传图片即时显示 function view_img(obj) { var file = $(obj); var fileObj = file[0]; var windowURL = window.URL || window.webkitURL; if(fileObj && fileObj.files && fileObj.files[0]){ var dataURL = windowURL.createObjectURL(fileObj.files[0]); }else{ var dataURL = file.val(); } console.log(dataURL); $("#img-view").empty(); $("#img-view").append('<img src="'+dataURL+'" >'); } // ajax提交图片进行识别并返回值 $(document).ready(function(){ var form = document.getElementById("uploadForm"); $("#startocr").click(function(e) { e.preventDefault();//必须 var oData = new FormData(form); $.ajax({ url: "http://netocr.com/api/recog.do" , type: 'POST', data: oData, async: true, cache: false, contentType: false, processData: false, success: function (returndata) { console.log(returndata); var resdata = returndata.cardsinfo; for (var i = 0; i < resdata.length; i++) { var items = resdata[i].items; $("#ocrname").val(items[0].content); $("#ocrposition").val(items[1].content); $("#ocrmobile").val(items[2].content); $("#ocrcompany").val(items[3].content); $("#ocraddress").val(items[4].content); $("#ocrtel").val(items[5].content); $("#ocrfax").val(items[6].content); $("#ocremail").val(items[7].content); $("#ocrwww").val(items[8].content); $("#ocrpostcode").val(items[9].content); } }, error: function (returndata) { alert("请求失败"); } }); }); });使用截图
2018年08月14日
473 阅读
0 评论
0 点赞
1
...
4
5