Java获取指定节点下的标签及nei'rong

图片说明
如图所示,我如何才能获得指定ContentItem节点下child2节点下的标签及内容,及获得

                <body>
                    <p>helloworld</p>
                    <input type='text'>
                </body>

然后将这段作为String输出。
目前我操作节点获取节点内容使用的方法是:

Document doc = null;
DocumentBuilder db = null;
DocumentBuilderFactory dbf = null;
String xxx = null;
try{
                dbf = DocumentBuilderFactory.newInstance();
                dbf.setValidating(false);
                db = dbf.newDocumentBuilder();
                doc = db.parse(xmlFile);
                xxx = doc.getELementByTagName("xxx").item(0).getTextContent()
}finally{
            ....
}

1个回答

你百度一下xpath,这个可以在js或java里面非常快速的定位到某个节点

xsb_20171227
今天是星期五 回复Aldwin: 无论是xpath还是dom4j,都是得到节点对象,这里面是包含了这个节点的属性、内容、标签等,全部信息
大约一年之前 回复
qiankunjie
Aldwin 快速定位的那这个和dom4j也差不多,但是这些都只能获取文本内容,无法获得标签本身,例如<p></p>。
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
PHP网站语句如何优化,希望和高手一起探讨下
我的网站是PHP网站,使用的数据库是MySQL 的目前直接用网上的采集插件出现了很多慢查询和扫全表的动作,自己也在对应的表里建立了普通索引,但还是无法得到解决,一直报错在SQL语句里,对于这块本人学习尚浅。 MySQL引擎是InnoDB,下面是索引截图: ![图片说明](https://img-ask.csdn.net/upload/201906/16/1560632068_941383.jpg) 报错语句: select url from ve123_links_temp where url like 'jmw.com.cn%' UPDATE `ve123_links_temp` SET `no_id`='1' WHERE url='http://app.hiapk.com/hiapk/about/agreement' 还请各位高手指点迷津,到底如何优化 语句: <?php //抓全站--- 多线程 function all_links_duo($site_id,$ceng,$include_word,$not_include_word) { global $db; $new_url=array(); $fenge=array(); $nei=1;//1代表只收内链 2代表外链 空代表所有 $numm=2;//开启多少线程 echo "<br><b>开始抓取第".$ceng."层</b><br>"; $ceng++; $row=$db->get_one("select * from ve123_links_temp where site_id='".$site_id."' and no_id='0'"); if(empty($row)){echo " ---------- 没有新链接了<br>";return;}//如果找不到新增加url,则结束 $query=$db->query("select * from ve123_links_temp where site_id='".$site_id."' and no_id='0'"); while($row=$db->fetch_array($query)) { $new_url[]=$row[url]; } $he_num = ceil(count($new_url)/$numm);//计算需要循环多少次 $fenge=array_chunk($new_url,$numm);//把数组分割成多少块数组 每块大小$numm /* echo "一共多少个"; echo count($new_url); echo "需要循环"; echo $he_num; echo "次<br>"; */ for($i=0;$i<=$he_num;$i++) { /*echo "开始循环第 ".$i." 次<br>"; print_r($fenge[$i]); echo "<br>";*/ $fen_url = array(); $fen_url = cmi($fenge[$i]); //需要把得到的数组 (数组只包括 网址和源码) 分析 写入数据库 , /*echo "<b>本次抓完的网址为</b>"; print_r($fen_url[url]); echo "<br>";*/ foreach ((array)$fen_url as $url => $file) { $links = array(); $temp_links = array(); $cha_temp = array(); $loy = array(); $new_links = array(); $cha_links = array(); $cha_links_num = array(); $links = _striplinks($file); //从htmlcode中提取网址 $links = _expandlinks($links, $url); //补全网址 $links=check_wai($links,$nei,$url); $links=array_values(array_unique($links)); $bianma = bianma($file); //获取得到htmlcode的编码 $file = Convert_File($file,$bianma); //转换所有编码为gb2312 $loy = clean_lry($file,$url,"html"); $title=$loy["title"]; //从数组中得到标题,赋值给title $pagesize=number_format(strlen($file)/1024, 0, ".", ""); $fulltxt=Html2Text($loy["fulltext"]); $description=$loy["description"]; //从数组中得到标题,赋值给description $keywords=$loy["keywords"]; //从数组中得到标题,赋值给keywords $lrymd5=md5($fulltxt); $updatetime=time(); if($title==""){$title=str_cut($fulltxt,65); } //根据url,更新内容 $array=array('lrymd5'=>$lrymd5,'title'=>$title,'fulltxt'=>$fulltxt,'description'=>$description,'keywords'=>$keywords,'pagesize'=>$pagesize,'updatetime'=>$updatetime); $db->update("ve123_links",$array,"url='".$url."'"); $all_num = count($links); //开始读取 ve123_links_temp 中所有site_id 为$site_id 的url 然后和抓取的 $links 数组比较,将得到的差集创建到 ve123_links_temp 中 $query=$db->query("select url from ve123_links_temp where url like '%".getdomain($url)."%'"); while($row=$db->fetch_array($query)) { $temp_links[]=rtrim($row[url],"/"); } $cha_temp=array_diff($links,$temp_links); foreach((array)$cha_temp as $value) { if(check_include($value, $include_word, $not_include_word )) { $arral=array('url'=>$value,'site_id'=>$site_id); $db->insert("ve123_links_temp",$arral); } } //开始读取 ve123_links 中所有site_id 为 $site_id 的url 然后和抓取的 $links 数组比较,将得到的差集创建到 ve123_links 中 合集则输出 已存在了 $query=$db->query("select url from ve123_links where url like '%".getdomain($url)."%'"); while($row=$db->fetch_array($query)) { $new_links[]=rtrim($row[url],"/"); } $cha_links=array_diff($links,$new_links); foreach((array)$cha_links as $value) { if(check_include($value, $include_word, $not_include_word )) { $array=array('url'=>$value,'site_id'=>$site_id,'level'=>'1'); $db->insert("ve123_links",$array); $cha_links_num[]=$value; } } $cha_num = count($cha_links_num); printLinksReport($cha_num, $all_num, $cl=0); echo "<a href=".$url." target=_blank>".$url. "</a><br>"; $arral=array('no_id'=>1); $db->update("ve123_links_temp",$arral,"url='$url'"); ob_flush(); flush(); } } all_links_duo($site_id,$ceng,$include_word,$not_include_word);//再次调用本函数开始循环 } //一键找站 function find_sites($site_id,$ceng) { global $db; $new_url=array(); $fenge=array(); $numm=20;//开启多少线程 echo "<br><b>开始抓取第".$ceng."层</b><br>"; $ceng++; $row=$db->get_one("select * from ve123_sites_temp where site_id='".$site_id."' and no_id='0'"); if(empty($row)){echo " ---------- 没有新链接了<br>";return;}//如果找不到新增加url,则结束 $query=$db->query("select * from ve123_sites_temp where site_id='".$site_id."' and no_id='0'"); while($row=$db->fetch_array($query)) { $new_url[]=$row[url]; } $he_num = ceil(count($new_url)/$numm);//计算需要循环多少次 $fenge=array_chunk($new_url,$numm);//把数组分割成多少块数组 每块大小$numm for($i=0;$i<=$he_num;$i++) { $fen_url = array(); $fen_url = cmi($fenge[$i]); //需要把得到的数组 (数组只包括 网址和源码) 分析 写入数据库 , foreach ((array)$fen_url as $url => $file) { $links = array(); $fen_link = array(); $nei_link = array(); $wai_link = array(); $new_temp = array(); $cha_temp = array(); $new_site = array(); $cha_site = array(); $new_lik = array(); $cha_lik = array(); $links = _striplinks($file); //从htmlcode中提取网址 $links = _expandlinks($links, $url); //补全网址 $fen_link=fen_link($links,$url); //把内链和外链分开 $nei_link=array_values(array_unique($fen_link[nei])); //过滤内链 重复的网址 $wai_link=GetSiteUrl($fen_link[wai]); //把外链都转换成首页 $wai_link=array_values(array_unique($wai_link)); //过滤外链 重复的网址 //读出 ve123_sites_temp 中所有 site_id=-1 and no_id=0 $query=$db->query("select url from ve123_sites_temp where site_id='".$site_id."'"); while($row=$db->fetch_array($query)) { $new_temp[]=$row[url]; } $cha_temp=array_diff($nei_link,$new_temp);//与内链进行比较 得出差集 //将差集创建到 ve123_sites_temp 中 foreach((array)$cha_temp as $value) { $arral=array('url'=>$value,'site_id'=>$site_id,'no_id'=>0); $db->insert("ve123_sites_temp",$arral); } //读出 ve123_sites 中所有 site_id=-1 global $db; $query=$db->query("select url from ve123_sites where site_no='".$site_id."'"); while($row=$db->fetch_array($query)) { $new_site[]=$row[url]; } $cha_site=array_diff($wai_link,$new_site);//与外链进行比较 得出差集 //将差集创建到 ve123_sites 中 foreach((array)$cha_site as $value) { $arral=array('url'=>$value,'site_no'=>$site_id); $db->insert("ve123_sites",$arral); } //读出 ve123_links 中所有 site_id=-1 global $db; global $db; $query=$db->query("select url from ve123_links where site_id='".$site_id."'"); while($row=$db->fetch_array($query)) { $new_lik[]=$row[url]; } $cha_lik=array_diff($wai_link,$new_lik);//与外链进行比较 得出差集 //将得到的差集 创建到 ve123_links foreach ((array)$cha_lik as $value) { $array=array('url'=>$value,'site_id'=>$site_id); $db->insert("ve123_links",$array); echo "<font color=#C60A00><b>抓取到:</b></font>"; echo "<a href=".$value." target=_blank>".$value."</a><br>"; } $arral=array('no_id'=>1); $db->update("ve123_sites_temp",$arral,"url='$url'"); ob_flush(); flush(); } } find_sites($site_id,$ceng);//再次调用本函数开始循环 } //一键更新 已抓站 function Update_sites($site_id) { global $db; $numm=20;//开启多少线程 $new_url = array(); $fenge = array(); $query=$db->query("select url from ve123_links where site_id='".$site_id."' and length(lrymd5)!=32"); while($row=$db->fetch_array($query)) { $new_url[]=$row[url]; } $he_num = ceil(count($new_url)/$numm);//计算需要循环多少次 $fenge=array_chunk($new_url,$numm);//把数组分割成多少块数组 每块大小$numm for($i=0;$i<=$he_num;$i++) { $fen_url = array(); $fen_url = cmi($fenge[$i]); //需要把得到的数组 (数组只包括 网址和源码) 分析 写入数据库 , foreach ((array)$fen_url as $url => $file) { $links = array(); $temp_links = array(); $cha_temp = array(); $loy = array(); $new_links = array(); $cha_links = array(); $cha_links_num = array(); $bianma = bianma($file); //获取得到htmlcode的编码 $file = Convert_File($file,$bianma); //转换所有编码为gb2312 if($file==-1) {echo "<b><font color=#C60A00>抓取失败</b></font> ".$url."<br>"; continue;} $loy = clean_lry($file,$url,"html"); //设置分析数组 $title=$loy["title"]; //从数组中得到标题,赋值给title $pagesize=number_format(strlen($file)/1024, 0, ".", ""); $fulltxt=Html2Text($loy["fulltext"]); $description=$loy["description"]; //从数组中得到标题,赋值给description $keywords=$loy["keywords"]; //从数组中得到标题,赋值给keywords $lrymd5=md5($fulltxt); $updatetime=time(); if($title==""){$title=str_cut($fulltxt,65); } //根据url,更新内容 echo "<b><font color=#0Ae600>已更新</font></b>"; echo $title; echo "<a href=".$url." target=_blank>".$url. "</a><br>"; $array=array('lrymd5'=>$lrymd5,'title'=>$title,'fulltxt'=>$fulltxt,'description'=>$description,'keywords'=>$keywords,'pagesize'=>$pagesize,'updatetime'=>$updatetime); $db->update("ve123_links",$array,"url='".$url."'"); } } } //一键找站 暂时不用的 function find_sites_($url) { $oldtime=time(); $site_id = -1; $numm=10; $links=array(); $fen_link=array(); $lrp =array(); $nei_link =array(); $wai_link =array(); $new_temp =array(); $cha_temp =array(); $new_site =array(); $cha_site =array(); $new_lik =array(); $cha_lik =array(); $fenge =array(); $lrp = cmi($url); $links = _striplinks($lrp[$url]); //从htmlcode中提取网址 $links = _expandlinks($links, $url); //补全网址 $fen_link=fen_link($links,$url); //把内链和外链分开 $nei_link=array_values(array_unique($fen_link[nei])); //过滤内链 重复的网址 $wai_link=GetSiteUrl($fen_link[wai]); //把外链都转换成首页 $wai_link=array_values(array_unique($wai_link)); //过滤外链 重复的网址 /*print_r($nei_link); echo "<br><br>"; print_r($wai_link);*/ //读出 ve123_sites_temp 中所有 site_id=-1 and no_id=0 global $db; $query=$db->query("select url from ve123_sites_temp where site_id='-1' and no_id='0'"); while($row=$db->fetch_array($query)) { $new_temp[]=$row[url]; } $cha_temp=array_diff($nei_link,$new_temp);//与内链进行比较 得出差集 //将差集创建到 ve123_sites_temp 中 foreach((array)$cha_temp as $value) { $arral=array('url'=>$value,'site_id'=>$site_id,'no_id'=>0); $db->insert("ve123_sites_temp",$arral); } //读出 ve123_temp 中所有 site_id=-1 global $db; global $db; $query=$db->query("select url from ve123_sites where site_no='-1'"); while($row=$db->fetch_array($query)) { $new_site[]=$row[url]; } $cha_site=array_diff($wai_link,$new_site);//与外链进行比较 得出差集 //将差集创建到 ve123_sites 中 foreach((array)$cha_site as $value) { $arral=array('url'=>$value,'site_no'=>$site_id); $db->insert("ve123_sites",$arral); } //读出 ve123_links 中所有 site_id=-1 global $db; global $db; $query=$db->query("select url from ve123_sites where site_id='-1'"); while($row=$db->fetch_array($query)) { $new_lik[]=$row[url]; } $cha_lik=array_diff($wai_link,$new_lik);//与外链进行比较 得出差集 //将得到的差集 创建到 ve123_links $he_num = ceil(count($cha_lik)/$numm);//计算需要循环多少次 $fenge=array_chunk($cha_lik,$numm);//把数组分割成多少块数组 每块大小$numm for($i=0;$i<=$he_num;$i++) { $fen_url = array(); $fen_url = cmi($fenge[$i]); //多线程开始采集 foreach ((array)$fen_url as $url => $file) { $bianma = bianma($file); //获取得到htmlcode的编码 $file = Convert_File($file,$bianma); //转换所有编码为gb2312 $loy = clean_lry($file,$url,"html"); //过滤 file 中标题等 到数组 $title=$loy["title"]; //从数组中得到标题,赋值给title $pagesize=number_format(strlen($file)/1024, 0, ".", ""); $fulltxt=Html2Text($loy["fulltext"]); $description=$loy["description"]; //从数组中得到标题,赋值给description $keywords=$loy["keywords"]; //从数组中得到标题,赋值给keywords $lrymd5=md5($fulltxt); $updatetime=time(); if($title==""){$title=str_cut($fulltxt,65); } //根据url,更新内容 $array=array('url'=>$value,'lrymd5'=>$lrymd5,'title'=>$title,'fulltxt'=>$fulltxt,'description'=>$description,'keywords'=>$keywords,'pagesize'=>$pagesize,'updatetime'=>$updatetime); $db->insert("ve123_links",$array); echo "<font color=#C60A00><b>抓取到:</b></font>".$title; echo "<a href=".$url." target=_blank>".$url."</a><br>"; } } $newtime=time(); echo " --- <b>用时:</b>"; echo date("H:i:s",$newtime-$oldtime-28800); echo "<br>"; del_links_temp($site_id); } //抓全站--- 单线程 function all_url_dan($url,$old,$nei,$ooo,$site_id,$include_word,$not_include_word) { if(!is_url($url)) { return false;} global $db,$config; $snoopy = new Snoopy; //国外snoopy程序 $snoopy->fetchlry($url); $links=$snoopy->resulry; if(!is_array($links)) {return;} $links=check_wai($links,$nei,$url); $links=array_values(array_unique($links)); $title=$snoopy->title; $fulltxt=$snoopy->fulltxt; $lrymd5=md5($fulltxt); $pagesize=$snoopy->pagesize; $description=$snoopy->description; $keywords=$snoopy->keywords; $updatetime=time(); if($title==""){$title=str_cut($fulltxt,65); } //读取url,更新内容 $array=array('lrymd5'=>$lrymd5,'title'=>$title,'fulltxt'=>$fulltxt,'description'=>$description,'keywords'=>$keywords,'pagesize'=>$pagesize,'updatetime'=>$updatetime); $db->update("ve123_links",$array,"url='".$url."'"); $all_num = count($links); $temp_links=array(); $cha_temp=array(); //开始读取 ve123_links_temp 中所有site_id 为$site_id 的url 然后和抓取的 $links 数组比较,将得到的差集创建到 ve123_links_temp 中 $query=$db->query("select url from ve123_links_temp where url like '%".getdomain($url)."%'"); while($row=$db->fetch_array($query)) { $temp_links[]=rtrim($row[url],"/"); } $cha_temp=array_diff($links,$temp_links); foreach((array)$cha_temp as $value) { $arral=array('url'=>$value,'site_id'=>$site_id); $db->insert("ve123_links_temp",$arral); } //开始读取 ve123_links 中所有site_id 为 $site_id 的url 然后和抓取的 $links 数组比较,将得到的差集创建到 ve123_links 中 合集则输出 已存在了 $query=$db->query("select url from ve123_links where url like '%".getdomain($url)."%'"); while($row=$db->fetch_array($query)) { $new_links[]=rtrim($row[url],"/"); } $cha_links=array_diff($links,$new_links); $cha_num = count($cha_links); foreach((array)$cha_links as $value) { if(check_include($value, $include_word, $not_include_word )) { $array=array('url'=>$value,'site_id'=>$site_id,'level'=>'1'); $db->insert("ve123_links",$array); } } printLinksReport($cha_num, $all_num, $cl=0); echo "<a href=".$old." target=_blank>".$old. "</a>"; ob_flush(); flush(); } //抓全站--- 单线程---不用的 function add_all_url_ ($url,$old,$numm,$ooo,$site_id,$include_word,$not_include_word) { if(!is_url($url)) { return false;} global $db,$config; $snoopy = new Snoopy; //国外snoopy程序 $snoopy->fetchlry($url); $links=$snoopy->resulry; if(!is_array($links)) {return;} $links=check_wai($links,$numm,$url); $links=array_values(array_unique($links)); $title=$snoopy->title; $fulltxt=$snoopy->fulltxt; $lrymd5=md5($fulltxt); $pagesize=$snoopy->pagesize; $description=$snoopy->description; $keywords=$snoopy->keywords; $updatetime=time(); if($title==""){$title=str_cut($fulltxt,65); } //读取url,更新内容 $array=array('lrymd5'=>$lrymd5,'title'=>$title,'fulltxt'=>$fulltxt,'description'=>$description,'keywords'=>$keywords,'pagesize'=>$pagesize,'updatetime'=>$updatetime); $db->update("ve123_links",$array,"url='".$url."'"); $all_num = count($links); $temp_links=array(); $cha_temp=array(); //开始读取 ve123_links_temp 中所有site_id 为$site_id 的url 然后和抓取的 $links 数组比较,将得到的差集创建到 ve123_links_temp 中 $query=$db->query("select url from ve123_links_temp where url like '%".getdomain($url)."%'"); while($row=$db->fetch_array($query)) { $temp_links[]=rtrim($row[url],"/"); } $cha_temp=array_diff($links,$temp_links); foreach((array)$cha_temp as $value) { $arral=array('url'=>$value,'site_id'=>$site_id); $db->insert("ve123_links_temp",$arral); } //开始读取 ve123_links 中所有site_id 为 $site_id 的url 然后和抓取的 $links 数组比较,将得到的差集创建到 ve123_links 中 合集则输出 已存在了 $query=$db->query("select url from ve123_links where url like '%".getdomain($url)."%'"); while($row=$db->fetch_array($query)) { $new_links[]=rtrim($row[url],"/"); } $he_links=array_intersect($links,$new_links); $he_num = count($he_links); $cha_links=array_diff($links,$new_links); $cha_num = count($cha_links); foreach((array)$cha_links as $value) { if(check_include($value, $include_word, $not_include_word )) { $array=array('url'=>$value,'site_id'=>$site_id,'level'=>'1'); $db->insert("ve123_links",$array); } } printLinksReport($cha_num, $all_num, $cl=0); echo "<a href=".$old." target=_blank>".$old. "</a>"; ob_flush(); flush(); } function printLinksReport($cha_num, $all_num, $cl) { global $print_results, $log_format; $cha_html = " <font color=\"blue\">页面包含<b>$all_num</b>条链接</font>。 <font color=\"red\"><b>$cha_num</b>条新链接。</font>\n"; $no_html = " <font color=\"blue\">页面包含<b>$all_num</b>条链接</font>。 没有新链接。\n"; if($cha_num==0) {print $no_html; flush();} else{print $cha_html;} } function add_links_insite($link,$old,$numm,$ooo,$site_id,$include_word,$not_include_word) { if(!is_url($link)) { return false; } global $db,$config; /* $spider=new spider; //系统自带蜘蛛 echo "<b>网站编码</b>(默认GB2312)<b>:"; $spider->url($link); echo "</b><br>"; $links= $spider->get_insite_links(); */ //$site_url=GetSiteUrl($link); $url_old=GetSiteUrl($old); echo "原始页=".$url_old." - - <"; echo "首层 id=".$site_id."> - - <"; echo "包含字段=".$include_word.">"; echo "<br>"; /*if($ooo==0) { $site=$db->get_one("select * from ve123_sites where url='".$url_old."'"); $site_id=$site["site_id"]; $include_word=$site["include_word"]; $not_include_word=$site["not_include_word"]; $spider_depth=$site["spider_depth"]; } */ $snoopy = new Snoopy; //国外snoopy程序 $snoopy->fetchlinks($link); $links=$snoopy->results; $links=check_wai($links,$numm,$link); $links=array_values(array_unique($links)); foreach((array)$links as $value) { $row=$db->get_one("select * from ve123_links_temp where url='".$value."'"); if(empty($row)) { $arral=array('url'=>$value,'site_id'=>$site_id); $db->insert("ve123_links_temp",$arral); } $value=rtrim($value,"/"); $row=$db->get_one("select * from ve123_links where url='".$value."'"); if (check_include($value, $include_word, $not_include_word )) { if(empty($row)&&is_url($value)) { echo "<font color=#C60A00><b>抓取到:</b></font>"; $array=array('url'=>$value,'site_id'=>$site_id,'level'=>'1'); $db->insert("ve123_links",$array); } else { echo "<b>已存在了:</b>";} echo "<a href=".$value." target=_blank>".$value. "</a><br>"; ob_flush(); flush(); //$row=$db->get_one("select * from ve123_links_temp where url='".$value."'"); // if(empty($row)&&is_url($value)) // { // $array=array('url'=>$value,'site_id'=>$site_id); // $db->insert("ve123_links_temp",$array); // } } } } //只保留内链或者外链 function check_wai($lry_all,$nei,$url) { $lry_nei=array();//站内链接数组 $lry_wai=array();//站外链接数组 $new_url=getdomain($url); if($nei=="") { foreach ((array)$lry_all as $value) { $lry_nei[]=rtrim($value,"/"); } return $lry_nei; } foreach ((array)$lry_all as $value) { if(getdomain($value)==$new_url) { $lry_nei[]=rtrim($value,"/"); //$lry_nei[]=$value; } else { $lry_wai[]=rtrim($value,"/"); } } if($nei==1){return $lry_nei;} if($nei==2){return $lry_wai;} } //把内链和外链分开 function fen_link($lry_all,$url) { $data=array();//站外链接数组 $new_url=getdomain($url); foreach ((array)$lry_all as $value) { if(getdomain($value)==$new_url) { $data['nei'][]=rtrim($value,"/"); } else { $data['wai'][]=rtrim($value,"/"); } } return $data; } function check_include($link, $include_word, $not_include_word) { $url_word = Array (); $not_url_word = Array (); $is_shoulu = true; if ($include_word != "") { $url_word = explode(",", $include_word); } if ($not_include_word != "") { $not_url_word = explode(",", $not_include_word); } foreach ($not_url_word as $v_key) { $v_key = trim($v_key); if ($v_key != "") { if (substr($v_key, 0, 1) == '*') { if (preg_match(substr($v_key, 1), $link)) { $is_shoulu = false; break; } } else { if (!(strpos($link, $v_key) === false)) { $is_shoulu = false; break; } } } } if ($is_shoulu && $include_word != "") { $is_shoulu = false; foreach ($url_word as $v_key) { $v_key = trim($v_key); if ($v_key != "") { if (substr($v_key, 0, 1) == '*') { if (preg_match(substr($v_key, 1), $link)) { $is_shoulu = true; break 2; } } else { if (strpos($link, $v_key) !== false) { $is_shoulu = true; break; } } } } } return $is_shoulu; } function add_links_site_fromtemp($in_url) { global $db; $domain=getdomain($in_url); $query=$db->query("select * from ve123_links_temp where url like '%".$domain."%' and no_id='0'"); while($row=$db->fetch_array($query)) { @$db->query("update ve123_links_temp set no_id='1' where url='".$row["url"]."'"); add_links_insite($row["url"],$row["url"],1,1); //sleep(3); } //sleep(5); add_links_site_fromtemp($in_url) ; } function insert_links($url) { global $db,$config; $spider=new spider; $spider->url($url); $links= $spider->links(); $sites= $spider->sites(); foreach($sites as $value) { $site_url=GetSiteUrl($link); $site=$db->get_one("select * from ve123_sites where url='".$site_url."'"); $site_id=$site["site_id"]; $row=$db->get_one("select * from ve123_links where url='".$value."'"); if(empty($row)&&is_url($value)) { echo $value."<br>"; $array=array('url'=>$value,'site_id'=>$site_id,'level'=>'0'); $db->insert("ve123_links",$array); } else { echo "已存在:".$value."<br>"; } ob_flush(); flush(); //sleep(1); $row=$db->get_one("select * from ve123_sites where url='".$value."'"); if(empty($row)&&is_url($value)) { $array=array('url'=>$value,'spider_depth'=>$config["spider_depth"],'addtime'=>time()); $db->insert("ve123_sites",$array); } } //sleep(1); foreach($links as $value) { $row=$db->get_one("select * from ve123_links_temp where url='".$value."'"); if(empty($row)&&is_url($value)) { $array=array('url'=>$value); $db->insert("ve123_links_temp",$array); } } } function GetUrl_AllSite($in_url) { global $db; $query=$db->query("select * from ve123_links_temp where url like '%".$in_url."%' and updatetime<='".(time()-(86400*30))."'"); while($row=$db->fetch_array($query)) { @$db->query("update ve123_links_temp set updatetime='".time()."' where url='".$row["url"]."'"); insert_links($row["url"]); //sleep(3); } //sleep(5); GetUrl_AllSite($in_url) ; } function Updan_link($url,$site_id) { global $db; $row=$db->get_one("select * from ve123_links_temp where url='".$url."'"); if(empty($row)) { $arral=array('url'=>$url,'site_id'=>$site_id); $db->insert("ve123_links_temp",$arral); } $row=$db->get_one("select * from ve123_links where url like '%".$url."%'"); if(empty($row)) { echo "<font color=#C60A00><b>抓取到:</b></font>".$url."<br>"; $array=array('url'=>$url,'site_id'=>$site_id,'level'=>'1'); $db->insert("ve123_links",$array); } else { echo "已存在:".$url."<br>"; } } function Updan_zhua($url,$site_id) { global $db; $lrp = array(); $links = array(); $fen_link = array(); $nei_link = array(); $new_temp = array(); $cha_temp = array(); $lrp = cmi($url); $links = _striplinks($lrp[$url]); //从htmlcode中提取网址 $links = _expandlinks($links, $url); //补全网址 $fen_link=fen_link($links,$url); //把内链和外链分开 $nei_link=array_values(array_unique($fen_link[nei])); //过滤内链 重复的网址 //读出 ve123_sites_temp 中所有 site_id=-1 and no_id=0 $query=$db->query("select url from ve123_sites_temp where site_id='".$site_id."'"); while($row=$db->fetch_array($query)) { $new_temp[]=$row[url]; } $cha_temp=array_diff($nei_link,$new_temp);//与内链进行比较 得出差集 //将差集创建到 ve123_sites_temp 中 foreach((array)$cha_temp as $value) { $arral=array('url'=>$value,'site_id'=>$site_id,'no_id'=>0); $db->insert("ve123_sites_temp",$arral); } } function Update_link($url) { global $db,$bug_url; $is_success=FALSE; $is_shoulu=FALSE; /*$spider=new spider; $spider->url($url); $title=$spider->title; $fulltxt=$spider->fulltxt; $lrymd5=md5($spider->fulltxt); $pagesize=$spider->pagesize; $keywords=$spider->keywords; $htmlcode=$spider->htmlcode; $description=$spider->description;*/ $snoopy = new Snoopy; //国外snoopy程序 $snoopy->fetchtext($url); $title=$snoopy->title; $fulltxt=$snoopy->fulltxt; $lrymd5=md5($fulltxt); $pagesize=$snoopy->pagesize; $description=$snoopy->description; $keywords=$snoopy->keywords; //echo "fulltxt=".$fulltxt."<br>"; $updatetime=time(); //$site_url=GetSiteUrl($url); //$site=$db->get_one("select * from ve123_sites where url='".$site_url."'"); //$site_id=$site["site_id"]; //echo "site_id".$site["site_id"]."<br>"; if($title==""){$title=str_cut($fulltxt,65); } echo "<b><font color=#0Ae600>已更新</font></b>"; echo $title; $array=array('lrymd5'=>$lrymd5,'title'=>$title,'fulltxt'=>$fulltxt,'description'=>$description,'keywords'=>$keywords,'pagesize'=>$pagesize,'updatetime'=>$updatetime); //$db->query("update ve123_links set updatetime='".time()."' where url='".$url."'"); //更新时间 //$s=array(); //$s=explode("?",$title); //$domain=GetSiteUrl($url); //$site=$db->get_one("select * from ve123_sites where url='".$domain."'"); $db->update("ve123_links",$array,"url='".$url."'"); $is_success=TRUE; if(empty($bug_url)) { exit(); } return $is_success; } function Update_All_Link_($in_url='',$days,$qiangzhi) { global $db; $new_url=array(); $fen_url=array(); $fenge=array(); $numm=20;//开启多少线程 //if($qiangzhi==0){ $lry="and strlen(lrymd5)!=32";} //else { ;} if(empty($in_url)) { $sql="select url from ve123_links where length(lrymd5)!=32 order by link_id desc"; } else { $sql="select url from ve123_links where url like '%".getdomain($in_url)."%' and length(lrymd5)!=32 order by link_id desc"; } echo $sql."<br>"; $query=$db->query($sql); while($row=$db->fetch_array($query)) { $new_url[]=$row[url]; } $he_num = ceil(count($new_url)/$numm);//计算需要循环多少次 //echo "<br><b>需要循环多少次=</b>".$he_num."<br>"; $fenge=array_chunk($new_url,$numm);//把数组分割成多少块数组 每块大小$numm for($i=0;$i<=$he_num;$i++) //for($i=0;$i<=1;$i++) { $fen_url=cmi($fenge[$i]); //需要把得到的数组 (数组只包括 网址和源码) 分析 写入数据库 , foreach ((array)$fen_url as $url => $file) { $bianma = bianma($file); //获取得到htmlcode的编码 $file = Convert_File($file,$bianma); //转换所有编码为gb2312 $lry = clean_lry($file,$url,"html"); $title=$lry["title"]; //从数组中得到标题,赋值给title $pagesize=number_format(strlen($file)/1024, 0, ".", ""); $fulltxt=Html2Text($lry["fulltext"]); $description=$lry["description"]; //从数组中得到标题,赋值给description $keywords=$lry["keywords"]; //从数组中得到标题,赋值给keywords $lrymd5=md5($fulltxt); $updatetime=time(); if($title==""){$title=str_cut($fulltxt,65); } echo "<b><font color=#0Ae600>已更新</font></b>"; echo $title; echo "<a href=".$url." target=_blank>".$url. "</a><br>"; $array=array('lrymd5'=>$lrymd5,'title'=>$title,'fulltxt'=>$fulltxt,'description'=>$description,'keywords'=>$keywords,'pagesize'=>$pagesize,'updatetime'=>$updatetime); $db->update("ve123_links",$array,"url='".$url."'"); } } } function cmi($links,$killspace=TRUE,$forhtml=TRUE,$timeout=6,$header=0,$follow=1){ $res=array();//用于保存结果 $mh = curl_multi_init();//创建多curl对象,为了几乎同时执行 foreach ((array)$links as $i => $url) { $conn[$url]=curl_init($url);//若url中含有gb2312汉字,例如FTP时,要在传入url的时候处理一下,这里不用 curl_setopt($conn[$url], CURLOPT_TIMEOUT, $timeout);//此时间须根据页面的HTML源码出来的时间,一般是在1s内的,慢的话应该也不会6秒,极慢则是在16秒内 curl_setopt($conn[$url], CURLOPT_HEADER, $header);//不返回请求头,只要源码 curl_setopt($conn[$url],CURLOPT_RETURNTRANSFER,1);//必须为1 curl_setopt($conn[$url], CURLOPT_FOLLOWLOCATION, $follow);//如果页面含有自动跳转的代码如301或者302HTTP时,自动拿转向的页面 curl_multi_add_handle ($mh,$conn[$url]);//关键,一定要放在上面几句之下,将单curl对象赋给多对象 } //下面一大步的目的是为了减少cpu的无谓负担,暂时不明,来自php.net的建议,几乎是固定用法 do { $mrc = curl_multi_exec($mh,$active);//当无数据时或请求暂停时,active=true } while ($mrc == CURLM_CALL_MULTI_PERFORM);//当正在接受数据时 while ($active and $mrc == CURLM_OK) {//当无数据时或请求暂停时,active=true,为了减少cpu的无谓负担,这一步很难明啊 if (curl_multi_select($mh) != -1) { do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } foreach ((array)$links as $i => $url) { $cinfo=curl_getinfo($conn[$url]);//可用于取得一些有用的参数,可以认为是header $res[$url]=curl_multi_getcontent($conn[$url]); if(!$forhtml){//节约内存 $res[$url]=NULL; } /*下面这一段放一些高消耗的程序代码,用来处理HTML,我保留的一句=NULL是要提醒,及时清空对象释放内存,此程序在并发过程中如果源码太大,内在消耗严重 //事实上,这里应该做一个callback函数或者你应该将你的逻辑直接放到这里来,我为了程序可重复,没这么做 preg_match_all($preg,$res[$i],$matchlinks); $res[$i]=NULL;*/ curl_close($conn[$url]);//关闭所有对象 curl_multi_remove_handle($mh , $conn[$url]); //用完马上释放资源 } curl_multi_close($mh);$mh=NULL;$conn=NULL;$links=NULL; return $res; } function clean_lry($file, $url, $type) { $data=array(); $file = preg_replace("/<link rel[^<>]*>/i", " ", $file); //$file = preg_replace("@<!--sphider_noindex-->.*?<!--\/sphider_noindex-->@si", " ",$file); $file = preg_replace("@<!--.*?-->@si", " ",$file); $file = preg_replace("@<script[^>]*?>.*?</script>@si", " ",$file); $file = preg_replace("/&nbsp;/", " ", $file); $file = preg_replace("/&raquo;/", " ", $file); $file=str_replace("'","‘",$file); $regs = Array (); preg_match("/<meta +name *=[\"']?description[\"']? *content=[\"']?([^<>'\"]+)[\"']?/i", $file, $regs); if (isset ($regs)) { $description = $regs[1]; $file = str_replace($regs[0], "", $file); } $regs = Array (); preg_match("/<meta +name *=[\"']?keywords[\"']? *content=[\"']?([^<>'\"]+)[\"']?/i", $file, $regs); if (isset ($regs)) { $keywords = $regs[1]; $file = str_replace($regs[0], "", $file); } $regs = Array (); $keywords = preg_replace("/[, ]+/", " ", $keywords); if (preg_match("@<title *>(.*?)<\/title*>@si", $file, $regs)) { $title = trim($regs[1]); $file = str_replace($regs[0], "", $file); } $file = preg_replace("@<style[^>]*>.*?<\/style>@si", " ", $file); //create spaces between tags, so that removing tags doesnt concatenate strings $file = preg_replace("/<[\w ]+>/", "\\0 ", $file); $file = preg_replace("/<\/[\w ]+>/", "\\0 ", $file); $file = strip_tags($file); //$fulltext = $file; //$file .= " ".$title; $file = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $file); $file = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $file); $file = strtolower($file); $file = preg_replace("/&[a-z]{1,6};/", " ", $file); $file = preg_replace("/[\*\^\+\?\\\.\[\]\^\$\|\{\)\(\}~!\"\/@#?%&=`?><:,]+/", " ", $file); $file = preg_replace("/\s+/", " ", $file); //$data['fulltext'] = $fulltext; $data['fulltext'] = addslashes($file); $data['title'] = addslashes($title); $data['description'] = $description; $data['keywords'] = $keywords; return $data; } function bianma($file) { preg_match_all("/<meta.+?charset=([-\w]+)/i",$file,$rs); $chrSet=strtoupper(trim($rs[1][0])); return $chrSet; } function Convert_File($file,$charSet) { $conv_file = html_entity_decode($file); $charSet = strtoupper(trim($charSet)); if($charSet != "GB2312"&&$charSet != "GBK") { $file=convertfile($charSet,"GB2312",$conv_file); if($file==-1){ return -1; } } return $file; } function convertfile($in_charset, $out_charset, $str) { //if(function_exists('mb_convert_encoding')) //{ $in_charset=explode(',',$in_charset); $encode_arr = array('GB2312','GBK','UTF-8','ASCII','BIG5','JIS','eucjp-win','sjis-win','EUC-JP'); $cha_temp=array_intersect($encode_arr,$in_charset); $cha_temp=implode('',$cha_temp); if(empty($in_charset)||empty($cha_temp)) { $encoded = mb_detect_encoding($str, $encode_arr); $in_charset=$encoded; } if(empty($in_charset)){ return -1; } echo $in_charset; return mb_convert_encoding($str, $out_charset, $in_charset); /*} else { require_once PATH.'include/charset.func.php'; $in_charset = strtoupper($in_charset); $out_charset = strtoupper($out_charset); if($in_charset == 'UTF-8' && ($out_charset == 'GBK' || $out_charset == 'GB2312')) { return utf8_to_gbk($str); } if(($in_charset == 'GBK' || $in_charset == 'GB2312') && $out_charset == 'UTF-8') { return gbk_to_utf8($str); } return $str; }*/ } function Update_All_Link($in_url='',$days,$qiangzhi) { global $db; if(empty($in_url)) { //$sql="select * from ve123_links where updatetime<='".(time()-(86400*$days))."' order by link_id desc";//echo $days."<br>"; $sql="select * from ve123_links where updatetime+86400 <".time()." order by link_id ";//echo $days."<br>"; } else { $sql="select * from ve123_links where url like '%".getdomain($in_url)."%' order by link_id desc";//echo $days."<br>"; //$sql="select * from ve123_links where url like '%".$in_url."%' order by link_id desc";//echo $days."<br>"; } //$sql="select * from ve123_links order by link_id"; echo $sql."<br>"; $query=$db->query($sql); while($row=$db->fetch_array($query)) { if(is_url($row["url"])) { // echo "呵呵呵呵".$row["lrymd5"]."<br>"; ob_flush(); flush(); //sleep(1); //if($row["lrymd5"]==""){ Update_link($row["url"],$row["lrymd5"]); } if($qiangzhi==1){ Update_link($row["url"]); } else { if(strlen($row["lrymd5"])!=32){ Update_link($row["url"]); } else {echo ""; } } echo ""; } ////sleep(2); } // echo "<br><b>全部更新完成</b> 完成日期:"; // echo date("Y年m月d日 H:i:s",time()); //sleep(2); // Update_All_Link($in_url) ; } function url_ce($val, $parent_url, $can_leave_domain) { global $ext, $mainurl, $apache_indexes, $strip_sessids; $valparts = parse_url($val); $main_url_parts = parse_url($mainurl); //if ($valparts['host'] != "" && $valparts['host'] != $main_url_parts['host'] && $can_leave_domain != 1) {return '';} reset($ext); while (list ($id, $excl) = each($ext)) if (preg_match("/\.$excl$/i", $val)) return ''; if (substr($val, -1) == '\\') {return '';} if (isset($valparts['query'])) {if ($apache_indexes[$valparts['query']]) {return '';}} if (preg_match("/[\/]?mailto:|[\/]?javascript:|[\/]?news:/i", $val)) {return '';} if (isset($valparts['scheme'])) {$scheme = $valparts['scheme'];} else {$scheme ="";} if (!($scheme == 'http' || $scheme == '' || $scheme == 'https')) {return '';} $regs = Array (); while (preg_match("/[^\/]*\/[.]{2}\//", $valpath, $regs)) { $valpath = str_replace($regs[0], "", $valpath); } $valpath = preg_replace("/\/+/", "/", $valpath); $valpath = preg_replace("/[^\/]*\/[.]{2}/", "", $valpath); $valpath = str_replace("./", "", $valpath); if(substr($valpath,0,1)!="/") {$valpath="/".$valpath;} $query = ""; if (isset($val_parts['query'])) {$query = "?".$val_parts['query'];} if ($main_url_parts['port'] == 80 || $val_parts['port'] == "") {$portq = "";} else {$portq = ":".$main_url_parts['port'];} return $val; } function iframe_ce($val, $parent_url, $can_leave_domain) { global $ext, $mainurl, $apache_indexes, $strip_sessids; $valparts = parse_url($val); $main_url_parts = parse_url($mainurl); //if ($valparts['host'] != "" && $valparts['host'] != $main_url_parts['host'] && $can_leave_domain != 1) {return '';} reset($ext); while (list ($id, $excl) = each($ext)) if (preg_match("/\.$excl$/i", $val)) return ''; if (substr($val, -1) == '\\') {return '';} if (isset($valparts['query'])) {if ($apache_indexes[$valparts['query']]) {return '';}} if (preg_match("/[\/]?mailto:|[\/]?javascript:|[\/]?news:/i", $val)) {return '';} if (isset($valparts['scheme'])) {$scheme = $valparts['scheme'];} else {$scheme ="";} if (!($scheme == 'http' || $scheme == '' || $scheme == 'https')) {return '';} $regs = Array (); while (preg_match("/[^\/]*\/[.]{2}\//", $valpath, $regs)) { $valpath = str_replace($regs[0], "", $valpath); } $valpath = preg_replace("/\/+/", "/", $valpath); $valpath = preg_replace("/[^\/]*\/[.]{2}/", "", $valpath); $valpath = str_replace("./", "", $valpath); if(substr($valpath,0,1)!="/") {$valpath="/".$valpath;} $query = ""; if (isset($val_parts['query'])) {$query = "?".$val_parts['query'];} if ($main_url_parts['port'] == 80 || $val_parts['port'] == "") {$portq = "";} else {$portq = ":".$main_url_parts['port'];} return $val; } function _striplinks($document) { $match = array(); $links = array(); preg_match_all("'<\s*(a\s.*?href|[i]*frame\s.*?src)\s*=\s*([\'\"])?([+:%\/\?~=&\\\(\),._a-zA-Z0-9-]*)'isx",$document,$links,PREG_PATTERN_ORDER); foreach ($links[3] as $val) { if (($a = url_ce($val, $url, $can_leave_domain)) != '') { $match[] = $a; } $checked_urls[$val[1]] = 1; } return $match; } function _expandlinks($links,$URI) { preg_match("/^[^\?]+/",$URI,$match); $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); $match = preg_replace("|/$|","",$match); $match_part = parse_url($match); $match_root = $match_part["scheme"]."://".$match_part["host"]; $URI_PARTS = parse_url($URI); $host = $URI_PARTS["host"]; $search = array( "|^http://".preg_quote($host)."|i", "|^(\/)|i", "|^(?!http://)(?!mailto:)|i", "|/\./|", "|/[^\/]+/\.\./|" ); $replace = array( "", $match_root."/", $match."/", "/", "/" ); $expandedLinks = preg_replace($search,$replace,$links); return $expandedLinks; } function foothtml() { echo "<div style=\"text-align:center;\"><a target=\"_blank\" href=\"http://www.php.com\"> Php</a></div>"; } ?> ``` ```
opencv knearest实现分类 求帮助!
我要用k最近邻方法实现分类,特征提取部分肯定没有问题,但是最后的分类结果总是惟一的(在本系统里是angry),在做的时候对照了网上的,没有问题啊,都是每个样本作为一行,只是网上的普遍是分为两类,我的是分为七类,但是为什么最后得到的结果总是惟一的呢?knn.find_nearest(tt,7,0,0,&nei,0)这句话总是返回一个不到1的浮点数,但是其实我训练分类器的时候用的knn.train(dst,labelsMat,Mat(),false,30,false )这句话里的labelmat都是从1到7的整数,这件事已经困扰我半个月了,实在解决不了,望大神帮助!
MS Active Accessibility 接口技术问题
#include <iostream> #include <windows.h> #include <oleacc.h> #include "atlbase.h" #include <winable.h> #pragma comment(lib,"oleacc.lib") BOOL FindChild (IAccessible* paccParent, char* szName, char* szRole, char* szClass, IAccessible** paccChild, VARIANT* pvarChild); UINT GetObjectState(IAccessible* pacc, VARIANT* pvarChild, LPTSTR lpszState, UINT cchState); void GetObjectName(IAccessible* paccChild, VARIANT* varChild, char szObjName[], int s); void GetObjectRole(IAccessible* paccChild, VARIANT* varChild, char szObjRole[], int s); void GetObjectClass(IAccessible* paccChild,char szObjClass[], int s); int main() { IAccessible* paccControl = NULL;//输入框的 IAccessible 接口 VARIANT varControl; //子ID。 HWND hWndMainWindow; IAccessible *paccMainWindow = NULL; HRESULT hr; //得到标题为"运行"的窗口的句柄 if(NULL == (hWndMainWindow = FindWindow(NULL, "运行"))) { MessageBox(NULL, "没有发现窗口!", "错误", MB_OK); } else { //通过窗口句柄得到窗口的 IAccessible 接口指针。 if(S_OK == (hr = AccessibleObjectFromWindow( hWndMainWindow, OBJID_WINDOW, IID_IAccessible, (void**)& paccMainWindow))) { //……我们可以通过这个指针paccMainWindow进行操作。 //paccMainWindow->Release(); //在文本输入框输入"regedit" printf("paccMainWindow:%d\n",paccMainWindow); if(1 == FindChild (paccMainWindow, "打开(O):", "可编辑文字", "Edit", &paccControl, &varControl)) { //在这里修改文本编辑框的值 printf("xiu gai wenben nei rong\n"); hr = paccControl->put_accValue(varControl,CComBSTR("regedit")); printf("xiu gai cheng gong\n"); paccControl->Release(); VariantClear(&varControl); } // 找到确定按钮,并执行默认动作。 if(1 == FindChild (paccMainWindow, "确定", "按下按钮", "Button", &paccControl, &varControl)) { //这里执行按钮的默认动作,即"按下这个按钮" hr = paccControl->accDoDefaultAction(varControl); paccControl->Release(); VariantClear(&varControl); } } } return 0; } BOOL FindChild (IAccessible* paccParent, char* szName, char* szRole, char* szClass, IAccessible** paccChild, VARIANT* pvarChild) { HRESULT hr; long numChildren; unsigned long numFetched; VARIANT varChild; int index; IAccessible* pCAcc = NULL; IEnumVARIANT* pEnum = NULL; IDispatch* pDisp = NULL; BOOL found = false; char szObjName[256], szObjRole[256], szObjClass[256], szObjState[256]; //得到父亲支持的IEnumVARIANT接口 if(paccParent==NULL) { printf("paccParent is NULL"); return false; } printf("enter findall\n"); hr = paccParent->QueryInterface(IID_IEnumVARIANT,(void**)&pEnum); if(pEnum) pEnum -> Reset(); //取得父亲拥有的可访问的子的数目 paccParent -> get_accChildCount(&numChildren); printf("numChildren:%d\n",numChildren); //搜索并比较每一个子ID,找到名字、角色、类与输入相一致的。 for(index = 1; index <= numChildren && !found; index++) { printf("%d\n",index); pCAcc = NULL; // 如果支持IEnumVARIANT接口,得到下一个子ID //以及其对应的 IDispatch 接口 printf("pEnum:%d\n",pEnum); if (pEnum) { VariantInit(&varChild); printf("varChild:%d\n",varChild); hr = pEnum -> Next(1, &varChild, &numFetched); if(hr==S_OK) printf("S_OK\n"); printf("varChild:%d\n",varChild); } else { //如果一个父亲不支持IEnumVARIANT接口,子ID就是它的序号 varChild.vt = VT_I4; varChild.lVal = index; } // 找到此子ID对应的 IDispatch 接口 if (varChild.vt == VT_I4) { //通过子ID序号得到对应的 IDispatch 接口 pDisp = NULL; printf("pDisp:%d\n",pDisp); hr = paccParent ->get_accChild(varChild,(IDispatch**)&pDisp); printf("pDisp:%d\n",pDisp); } else //如果父支持IEnumVARIANT接口可以直接得到子IDispatch 接口 pDisp = varChild.pdispVal; // 通过 IDispatch 接口得到子的 IAccessible 接口 pCAcc if (pDisp) { printf("pCAcc:%d\n",pCAcc); hr = pDisp->QueryInterface(IID_IAccessible, (void**)&pCAcc); printf("pCAcc:%d\n",pCAcc); hr = pDisp->Release(); } // Get information about the child if(pCAcc) { //如果子支持IAccessible 接口,那么子ID就是CHILDID_SELF VariantInit(&varChild); varChild.vt = VT_I4; varChild.lVal = CHILDID_SELF; *paccChild = pCAcc; } else //如果子不支持IAccessible 接口 *paccChild = paccParent; //跳过了有不可访问状态的元素 GetObjectState(*paccChild, &varChild, szObjState, sizeof(szObjState)); if(NULL != strstr(szObjState, "unavailable")) { if(pCAcc) pCAcc->Release(); continue; } //通过get_accName得到Nam GetObjectName(*paccChild, &varChild, szObjName, sizeof(szObjName)); //通过get_accRole得到Role GetObjectRole(*paccChild, &varChild, szObjRole, sizeof(szObjRole)); //通过WindowFromAccessibleObject和GetClassName得到Class GetObjectClass(*paccChild, szObjClass, sizeof(szObjClass)); //以上实现代码比较简单,大家自己看代码吧。 //如果这些参数与输入相符或输入为NULL if ((NULL==szName || 0==strcmp(szName, szObjName))&& (NULL==szRole || 0==strcmp(szRole, szObjRole)) && (NULL==szClass || 0==strcmp(szClass, szObjClass))) { found = true; *pvarChild = varChild; break; } if(!found && pCAcc) { // 以这次得到的子接口为父递归调用 printf("findall again"); found = FindChild(pCAcc, szName, szRole, szClass, paccChild, pvarChild); if(*paccChild != pCAcc) pCAcc->Release(); } }//End for // Clean up if(pEnum) pEnum -> Release(); printf("exit findall\n"); return found; } // UI元素的状态也表示成整型形式。因为一个状态可以有多个值, //例如可选的、可做焦点的,该整数是反映这些值的位的或操作结果。 //将这些或数转换成相应的用逗号分割的状态字符串。 UINT GetObjectState(IAccessible* pacc, VARIANT* pvarChild, LPTSTR lpszState, UINT cchState) { HRESULT hr; VARIANT varRetVal; *lpszState = 0; VariantInit(&varRetVal); hr = pacc->get_accState(*pvarChild, &varRetVal); if (!SUCCEEDED(hr)) return(0); DWORD dwStateBit; int cChars = 0; if (varRetVal.vt == VT_I4) { // 根据返回的状态值生成以逗号连接的字符串。 for (dwStateBit = STATE_SYSTEM_UNAVAILABLE; dwStateBit < STATE_SYSTEM_ALERT_HIGH; dwStateBit <<= 1) { if (varRetVal.lVal & dwStateBit) { cChars += GetStateText(dwStateBit, lpszState + cChars, cchState - cChars); *(lpszState + cChars++) = ','; } } if(cChars > 1) *(lpszState + cChars - 1) = '\0'; } else if (varRetVal.vt == VT_BSTR) { WideCharToMultiByte(CP_ACP, 0, varRetVal.bstrVal, -1, lpszState, cchState, NULL, NULL); } VariantClear(&varRetVal); return(lstrlen(lpszState)); } void GetObjectName(IAccessible* paccChild, VARIANT* varChild, char szObjName[], int s) { printf("getname\n"); if(paccChild==NULL) { printf("IAccessible is NULL"); return; } CComBSTR buf; paccChild->get_accName(*varChild,&buf); unsigned int i,len; len=buf.Length(); memset(szObjName,0,s); for(i=0;i<len;i++) *(szObjName+i)=*(buf.m_str+i); } void GetObjectRole(IAccessible* paccChild, VARIANT* varChild, char szObjRole[], int s) { printf("getrole\n"); if(paccChild==NULL) { printf("IAccessible is NULL"); return; } VARIANT buf; paccChild->get_accRole(*varChild,&buf); buf.vt=VT_I2; szObjRole=(char*)buf.bstrVal; } void GetObjectClass(IAccessible* paccChild,char szObjClass[], int s) { printf("getclass\n"); if(paccChild==NULL) { printf("IAccessible is NULL\n"); return; } HWND hwnd; LPSTR buf; WindowFromAccessibleObject(paccChild,&hwnd); GetClassName(hwnd,buf,s); szObjClass=buf; printf("getclass end\n"); } 我第二次for循环一直运行出错,pDisp的值一直为0
【C#】菜鸟一枚,有关汉字转拼音的编程问题,谢!
下面粘贴的是书上的源代码,有以下几个问题: 1.asc=M1*256+M2-65536 这个式子是什么含义? 2.为什么计算机内有自己的编码系统,还要自己去定义拼音编码数组和相对应的拼音数组呢? 3.这个编程的思路是怎样的呢? 菜鸟一枚,特别晕菜,希望给予指点。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; namespace ChineseToABC { class Program { static void Main(string[] args) { while (true) { Console.WriteLine("请输入要转换的内容:"); string str = Console.ReadLine(); Regex reg = new Regex("^[\u4e00-\u9fa5]$");//验证输入是否为汉字 byte[] arr = new byte[2];//定义字节数组 string pystr = "";//定义字符串变量并添加引用 char[] mChar = str.ToCharArray();//获取汉字对应的字符数组 Console.WriteLine("转换后的拼音:"+GetStr(mChar, pystr, reg, arr)+"\n");//返回获取到的汉字拼音 } } //定义拼音区编码数组 private static int[] getValue = new int[] { -20319,-20317,-20304,-20295,-20292,-20283,-20265,-20257,-20242,-20230,-20051,-20036, -20032,-20026,-20002,-19990,-19986,-19982,-19976,-19805,-19784,-19775,-19774,-19763, -19756,-19751,-19746,-19741,-19739,-19728,-19725,-19715,-19540,-19531,-19525,-19515, -19500,-19484,-19479,-19467,-19289,-19288,-19281,-19275,-19270,-19263,-19261,-19249, -19243,-19242,-19238,-19235,-19227,-19224,-19218,-19212,-19038,-19023,-19018,-19006, -19003,-18996,-18977,-18961,-18952,-18783,-18774,-18773,-18763,-18756,-18741,-18735, -18731,-18722,-18710,-18697,-18696,-18526,-18518,-18501,-18490,-18478,-18463,-18448, -18447,-18446,-18239,-18237,-18231,-18220,-18211,-18201,-18184,-18183, -18181,-18012, -17997,-17988,-17970,-17964,-17961,-17950,-17947,-17931,-17928,-17922,-17759,-17752, -17733,-17730,-17721,-17703,-17701,-17697,-17692,-17683,-17676,-17496,-17487,-17482, -17468,-17454,-17433,-17427,-17417,-17202,-17185,-16983,-16970,-16942,-16915,-16733, -16708,-16706,-16689,-16664,-16657,-16647,-16474,-16470,-16465,-16459,-16452,-16448, -16433,-16429,-16427,-16423,-16419,-16412,-16407,-16403,-16401,-16393,-16220,-16216, -16212,-16205,-16202,-16187,-16180,-16171,-16169,-16158,-16155,-15959,-15958,-15944, -15933,-15920,-15915,-15903,-15889,-15878,-15707,-15701,-15681,-15667,-15661,-15659, -15652,-15640,-15631,-15625,-15454,-15448,-15436,-15435,-15419,-15416,-15408,-15394, -15385,-15377,-15375,-15369,-15363,-15362,-15183,-15180,-15165,-15158,-15153,-15150, -15149,-15144,-15143,-15141,-15140,-15139,-15128,-15121,-15119,-15117,-15110,-15109, -14941,-14937,-14933,-14930,-14929,-14928,-14926,-14922,-14921,-14914,-14908,-14902, -14894,-14889,-14882,-14873,-14871,-14857,-14678,-14674,-14670,-14668,-14663,-14654, -14645,-14630,-14594,-14429,-14407,-14399,-14384,-14379,-14368,-14355,-14353,-14345, -14170,-14159,-14151,-14149,-14145,-14140,-14137,-14135,-14125,-14123,-14122,-14112, -14109,-14099,-14097,-14094,-14092,-14090,-14087,-14083,-13917,-13914,-13910,-13907, -13906,-13905,-13896,-13894,-13878,-13870,-13859,-13847,-13831,-13658,-13611,-13601, -13406,-13404,-13400,-13398,-13395,-13391,-13387,-13383,-13367,-13359,-13356,-13343, -13340,-13329,-13326,-13318,-13147,-13138,-13120,-13107,-13096,-13095,-13091,-13076, -13068,-13063,-13060,-12888,-12875,-12871,-12860,-12858,-12852,-12849,-12838,-12831, -12829,-12812,-12802,-12607,-12597,-12594,-12585,-12556,-12359,-12346,-12320,-12300, -12120,-12099,-12089,-12074,-12067,-12058,-12039,-11867,-11861,-11847,-11831,-11798, -11781,-11604,-11589,-11536,-11358,-11340,-11339,-11324,-11303,-11097,-11077,-11067, -11055,-11052,-11045,-11041,-11038,-11024,-11020,-11019,-11018,-11014,-10838,-10832, -10815,-10800,-10790,-10780,-10764,-10587,-10544,-10533,-10519,-10331,-10329,-10328, -10322,-10315,-10309,-10307,-10296,-10281,-10274,-10270,-10262,-10260,-10256,-10254 }; //定义拼音数组 private static string[] getStr = new string[] { "A","Ai","An","Ang","Ao","Ba","Bai","Ban","Bang","Bao","Bei","Ben", "Beng","Bi","Bian","Biao","Bie","Bin","Bing","Bo","Bu","Ba","Cai","Can", "Cang","Cao","Ce","Ceng","Cha","Chai","Chan","Chang","Chao","Che","Chen","Cheng", "Chi","Chong","Chou","Chu","Chuai","Chuan","Chuang","Chui","Chun","Chuo","Ci","Cong", "Cou","Cu","Cuan","Cui","Cun","Cuo","Da","Dai","Dan","Dang","Dao","De", "Deng","Di","Dian","Diao","Die","Ding","Diu","Dong","Dou","Du","Duan","Dui", "Dun","Duo","E","En","Er","Fa","Fan","Fang","Fei","Fen","Feng","Fo", "Fou","Fu","Ga","Gai","Gan","Gang","Gao","Ge","Gei","Gen","Geng","Gong", "Gou","Gu","Gua","Guai","Guan","Guang","Gui","Gun","Guo","Ha","Hai","Han", "Hang","Hao","He","Hei","Hen","Heng","Hong","Hou","Hu","Hua","Huai","Huan", "Huang","Hui","Hun","Huo","Ji","Jia","Jian","Jiang","Jiao","Jie","Jin","Jing", "Jiong","Jiu","Ju","Juan","Jue","Jun","Ka","Kai","Kan","Kang","Kao","Ke", "Ken","Keng","Kong","Kou","Ku","Kua","Kuai","Kuan","Kuang","Kui","Kun","Kuo", "La","Lai","Lan","Lang","Lao","Le","Lei","Leng","Li","Lia","Lian","Liang", "Liao","Lie","Lin","Ling","Liu","Long","Lou","Lu","Lv","Luan","Lue","Lun", "Luo","Ma","Mai","Man","Mang","Mao","Me","Mei","Men","Meng","Mi","Mian", "Miao","Mie","Min","Ming","Miu","Mo","Mou","Mu","Na","Nai","Nan","Nang", "Nao","Ne","Nei","Nen","Neng","Ni","Nian","Niang","Niao","Nie","Nin","Ning", "Niu","Nong","Nu","Nv","Nuan","Nue","Nuo","O","Ou","Pa","Pai","Pan", "Pang","Pao","Pei","Pen","Peng","Pi","Pian","Piao","Pie","Pin","Ping","Po", "Pu","Qi","Qia","Qian","Qiang","Qiao","Qie","Qin","Qing","Qiong","Qiu","Qu", "Quan","Que","Qun","Ran","Rang","Rao","Re","Ren","Reng","Ri","Rong","Rou", "Ru","Ruan","Rui","Run","Ruo","Sa","Sai","San","Sang","Sao","Se","Sen", "Seng","Sha","Shai","Shan","Shang","Shao","She","Shen","Sheng","Shi","Shou","Shu", "Shua","Shuai","Shuan","Shuang","Shui","Shun","Shuo","Si","Song","Sou","Su","Suan", "Sui","Sun","Suo","Ta","Tai","Tan","Tang","Tao","Te","Teng","Ti","Tian", "Tiao","Tie","Ting","Tong","Tou","Tu","Tuan","Tui","Tun","Tuo","Wa","Wai", "Wan","Wang","Wei","Wen","Weng","Wo","Wu","Xi","Xia","Xian","Xiang","Xiao", "Xie","Xin","Xing","Xiong","Xiu","Xu","Xuan","Xue","Xun","Ya","Yan","Yang", "Yao","Ye","Yi","Yin","Ying","Yo","Yong","You","Yu","Yuan","Yue","Yun", "Za", "Zai","Zan","Zang","Zao","Ze","Zei","Zen","Zeng","Zha","Zhai","Zhan", "Zhang","Zhao","Zhe","Zhen","Zheng","Zhi","Zhong","Zhou","Zhu","Zhua","Zhuai","Zhuan", "Zhuang","Zhui","Zhun","Zhuo","Zi","Zong","Zou","Zu","Zuan","Zui","Zun","Zuo" }; private static string GetStr(char[] mChar, string pystr, Regex reg, byte[] arr) { int asc = 0, M1 = 0, M2 = 0; for (int j = 0; j < mChar.Length; j++) { if (reg.IsMatch(mChar[j].ToString()))//如果输入的是汉字 { arr = System.Text.Encoding.Default.GetBytes(mChar[j].ToString()); M1 = (short)(arr[0]); M2 = (short)(arr[1]); **asc = M1 * 256 + M2 - 65536;** if (asc > 0 && asc < 160) { pystr += mChar[j]; } else { switch (asc) { case -9254: pystr += "Zhen"; break; case -8985: pystr += "Qian"; break; case -5463: pystr += "Jia"; break; case -8274: pystr += "Ge"; break; case -5448: pystr += "Ga"; break; case -5447: pystr += "La"; break; case -4649: pystr += "Chen"; break; case -5436: pystr += "Mao"; break; case -5213: pystr += "Mao"; break; case -3597: pystr += "Die"; break; case -5659: pystr += "Tian"; break; default: for (int i = (getValue.Length - 1); i >= 0; i--) { if (getValue[i] <= asc)//判断汉字的拼音区编码是否在指定范围内 { pystr += getStr[i];//如果不超出范围则获取对应的拼音 break; } } break; } } } else//如果不是汉字 { pystr += mChar[j].ToString();//如果不是汉字则返回 } } return pystr; } } }
记事本开发在edittext中插入图片的问题
# NoteEdit.java public class NoteEdit extends AppCompatActivity { private EditText edit_content; private Database DBHelper; public int enter_state = 0;//用来区分是新建一个note还是更改原来的note public String last_content;//用来获取edittext内容 @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.editnote); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_edit); setSupportActionBar(toolbar); InitView(); } private Bitmap resizeImage(Bitmap bitmap, int wid, int hei) { Bitmap BitmapOrg = bitmap; int width = BitmapOrg.getWidth(); int height = BitmapOrg.getHeight(); int newWidth = wid; int newHeight = hei; float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizeBipmap = Bitmap.createBitmap(BitmapOrg, 0, 0, width, height, matrix, true); return resizeBipmap; } private void InitView() { edit_content = (EditText) findViewById(R.id.edit_content); //fab_ok = (FloatingActionButton) findViewById(R.id.fab_ok); DBHelper = new Database(this); //获取此时时刻时间 Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String dateString = sdf.format(date); //接收内容和id Bundle myBundle = this.getIntent().getExtras(); last_content = myBundle.getString("info"); enter_state = myBundle.getInt("enter_state"); edit_content.setText(last_content); } @Override protected void onPause() { super.onPause(); SQLiteDatabase db = DBHelper.getReadableDatabase(); String content = edit_content.getText().toString(); if (enter_state == 0) { if (!content.equals("")) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String dateString = sdf.format(date); Bundle data = new Bundle(); data.putString("nei",content); Intent intent = new Intent(NoteEdit.this,Display.class); intent.putExtra("neirong",data); ContentValues values = new ContentValues(); values.put("content", content); values.put("date", dateString); db.insert("note", null, values); finish(); } } else { ContentValues values = new ContentValues(); values.put("content", content); db.update("note", values, "content=?", new String[]{last_content}); finish(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_paint: Intent getImage = new Intent(Intent.ACTION_PICK, null); getImage.addCategory(Intent.CATEGORY_OPENABLE); getImage.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); getImage.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(getImage, 1); break; } return true; } protected void onActivityResult(int requestCode, int resultCode, Intent intent) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, intent); ContentResolver resolver = getContentResolver(); if (resultCode == RESULT_OK) { if (requestCode == 1) { Uri originalUri = intent.getData(); try { Bitmap originalBitmap = BitmapFactory.decodeStream(resolver .openInputStream(originalUri)); Bitmap bitmap = resizeImage(originalBitmap, 100, 100); } catch (FileNotFoundException e) { e.printStackTrace(); } edit_content = (EditText) findViewById(R.id.edit_content); insertIntoEditText(getBitmapMime(bitmap, originalUri)); } } } private SpannableString getBitmapMime(int pic, Uri uri) { String path = uri.getPath(); SpannableString ss = new SpannableString(path); ImageSpan span = new ImageSpan(this, pic); ss.setSpan(span, 0, path.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return ss; } private void insertIntoEditText(SpannableString ss) { Editable et = edit_content.getText();// 先获取Edittext中的内容 int start = edit_content.getSelectionStart(); et.insert(start, ss);// 设置ss要添加的位置 edit_content.setText(et);// 把et添加到Edittext中 edit_content.setSelection(start + ss.length());// 设置Edittext中光标在最后面显示 } @Override public void onStart() { super.onStart(); } @Override public void onStop() { super.onStop(); } } # Display.java public class Display extends AppCompatActivity{ EditText display; protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.display); display = (EditText) findViewById(R.id.display); String imagePath = getIntent().getBundleExtra("neirong").getString( "nei"); SpannableString ss = new SpannableString(imagePath); Pattern p=Pattern.compile("/mnt/sdcard/.+?\\.\\w{3}"); Matcher m=p.matcher(imagePath); while(m.find()){ Bitmap bm = BitmapFactory.decodeFile(m.group()); Bitmap rbm = resizeImage(bm, 100, 100); ImageSpan span = new ImageSpan(this, rbm); ss.setSpan(span, m.start(), m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } display.setText(ss); } private Bitmap resizeImage(Bitmap bitmap, int wid, int hei) { Bitmap BitmapOrg = bitmap; int width = BitmapOrg.getWidth(); int height = BitmapOrg.getHeight(); int newWidth = wid; int newHeight = hei; float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizeBipmap = Bitmap.createBitmap(BitmapOrg, 0, 0, width, height, matrix, true); return resizeBipmap; } } 为什么我在记事界面点击插入图片后程序崩溃了 错误日志:java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:37152 flg=0x1 }} to activity {com.example.mingnote/com.example.mingnote.NoteEdit}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Rect android.graphics.drawable.Drawable.getBounds()' on a null object reference
org.apache.jasper.JasperException处理异常如何解决?
初学JavaEE碰到的问题,求大神帮帮忙 这是源代码 ``` <%@ page contentType="text/html;charset=gb2312" pageEncoding="utf-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <title>网上书店</title> <link href="css/bookstore.css" rel="stylesheet" type="text/css"/> </head> <body> <div class="head"> <div class="head_left"> <a href="#"> <img hspace="11" src="picture/logo_dear.gif" vspace="5"> </a> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;书店提供专业服务 </div> <div class="head_right"> <div class="head_right_nei"> <div class="head_top"> <div class="head_buy"> <strong> <a href="/bookstore/showCart.jsp"> <img height="15" src="picture/buy01.jpg" width="16">&nbsp;购物车 </a> </strong> | <a href="#">用户FAQ</a> </div> </div> <div class="head_middle"> <a class="title01" href="index.jsp"> <span>&nbsp;&nbsp;首页&nbsp;&nbsp;</span> </a> <s:if test = "session.user == null"> <a class="title01" href="login.jsp"> <span>&nbsp;&nbsp;登陆&nbsp;&nbsp;</span> </a> </s:if> <s:else> <a class="title01" href="logout.action"> <span>&nbsp;&nbsp;注销&nbsp;&nbsp;</span> </a> </s:else> <a class="title01" href="register.jsp"> <span>&nbsp;&nbsp;注册&nbsp;&nbsp;</span> </a> <a class="title01" href="#"> <span>&nbsp;联系我们&nbsp;&nbsp;&nbsp;</span> </a> <a class="title01" href="#"> <span>&nbsp;网站地图&nbsp;&nbsp;&nbsp;</span> </a> </div> <div class="head_bottom"> <form action="searchBook.action" method="post"> <input type="text" name="bookname" size="50" align="middle"/> <input type="image" name="submit" src="picture/search02.jpg" align="top" style="width: 48px; height: 22px"/> </form> </div> </div> </div> </div> </body> </html> ``` ![图片说明](https://img-ask.csdn.net/upload/201812/31/1546250296_572812.png)
关于安卓Bitmap,怎样写一个缩放图片的方法?
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.editnote); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_edit); setSupportActionBar(toolbar); EditText editText = (EditText)findViewById(R.id.edit_content); String imagePath = getIntent().getBundleExtra("neirong").getString( "nei"); SpannableString ss = new SpannableString(imagePath); Pattern p=Pattern.compile("/mnt/sdcard/.+?\\.\\w{3}"); Matcher m=p.matcher(imagePath); while(m.find()){ Bitmap bm = BitmapFactory.decodeFile(m.group()); Bitmap rbm = resizeImage(bm, 100, 100); ImageSpan span = new ImageSpan(this, rbm); ss.setSpan(span, m.start(), m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } editText.setText(ss); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); InitView(); } 对应如上代码,resizeImage方法该怎么写?
请问怎样实现<iframe>父子页面的联动查询?
情况是这样:我在父页面上面插入了查询条件,然后在子页面上显示数据,怎样能够使 父页面上的条件完成子页面的查询, ![图片说明](https://img-ask.csdn.net/upload/201809/27/1538016297_159410.png) ``` <body style="background-color: #f8f6f2"> <div> <div id="nei"> <p><span class="title" >查询条件</span></p> <form id="jyBlacklistForm" onkeydown="if(event.keyCode==13){doSearch();return false;}"> <div style="margin-top: 15px;margin-left: 100px"> <label >黑名单有效期:</label> <input class="dts search-inp Wdate search-group-inp" type="text" style="width: 105px" name="jyBlenddate_begin" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" placeholder="请选择开始日期"/> <span>至</span> <input class="dts search-inp Wdate search-group-inp" type="text" style="width: 105px" name="jyBlenddate_end" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" placeholder="请选择结束日期"/> <label style="margin-left: 25px">提交人类型:</label> <input id="jycodet" type="text" name="jyBlpersontype" value='' style="display:none;" /> <select id="jycode" class="inputa" onChange="change()"> <option>---请选择---</option> <c:forEach items="${list}" var="area"> <option value='${area["id"]}'>${area["jy_class"]}</option> </c:forEach> </select> <label style="margin-left: 25px">全部:</label> <input class="inputa"type="text"> <label style="margin-left: 25px">黑名单号码:</label> <input class="inputa"type="text" name="jyBltelnum" id="jyBltelnum"> </div> <div style="margin-top: 15px;margin-left: 100px;margin-bottom: 25px;"> <label >黑名单设定期:</label> <input class="dts search-inp Wdate search-group-inp" type="text" style="width: 105px" name="jyBlbegindate_begin" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" placeholder="请选择开始日期"/> <span>至</span> <input class="dts search-inp Wdate search-group-inp" type="text" style="width: 105px" name="jyBlbegindate_end" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" placeholder="请选择结束日期"/> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <button type="button" class="tool-btn tool-btn-default tool-btn-xs" onclick="add('新增','jyBlacklistController.do?goAdd','jyBlacklistList',768,500);shenhe()"> <i class="fa fa-plus"></i> <span>新增</span> </button> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <button type="button" id="shenhe" class="tool-btn tool-btn-default tool-btn-xs" > <i class="fa fa-edit"></i> <span>审核</span> </button> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <button type="button" class="tool-btn tool-btn-default tool-btn-xs" onclick="add('录入','jyBlacklistController.do?goAdd','jyBlacklistList',768,500)"> <i class="fa fa-plus"></i> <span>解除</span> </button> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <button type="button" class="tool-btn tool-btn-default tool-btn-xs" onclick="deleteALLSelect('批量删除','jyBlacklistController.do?doBatchDel','jyBlacklistList',null,null)"> <i class="fa fa-trash"></i> <span>删除</span> </button> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <button type="button" class="tool-btn tool-btn-default tool-btn-xs" onclick="doSearch()"> <i class="fa fa-search"></i> <span>查询</span> </button> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <button type="button" class="tool-btn tool-btn-default tool-btn-xs" onclick="resetSearch()"> <i class="fa fa-refresh"></i> <span>重置</span> </button> </div> </form> </div> <div id="nei" class="shua"> <iframe style="margin: 25px;width: 95%;height: 243px" src="jyBlacklistController.do?Findlist"></iframe> </div> ```
代码有问题,求大神解答
![图片说明](https://img-ask.csdn.net/upload/201704/01/1491024644_152717.png) ``` #include<stdio.h> #include<malloc.h> #include<iostream> using namespace std; #define MAXSize 10000 struct { char data; int n; }nei[]={{'=',0},{'(',1},{'+',3},{'-',3},{'*',5},{'/',5},{')',6}}, wai[]={{'=',0},{'(',6},{'+',2},{'-',2},{'*',4},{'/',4},{')',1}}; struct sqstack { char data; struct sqstack *next; }; void initstack(struct sqstack* &); void push(struct sqstack* &,struct sqstack *,struct sqstack *); void jisuan(struct sqstack *); int waishu(char ); int main() { struct sqstack *L1,*L,*L2; int i,n; initstack(L); initstack(L1); initstack(L2); scanf("%d",&n); for(i=0;i<n;i++) { L->next=NULL; push(L,L1,L2); jisuan(L); if(i!=n-1)printf("\n"); } return 0; } void initstack(struct sqstack* &L) { L=new sqstack; L->next=NULL; } int neishu(char c) { int i=0; for(i=0;i<7;i++) { if(nei[i].data==c) return nei[i].n; } } int waishu(char c) { int i=0; for(i=0;i<7;i++) { if(wai[i].data==c) return wai[i].n; } } void push(struct sqstack* &L,struct sqstack *L1,struct sqstack *L2) { struct sqstack *newnode=NULL,*p=NULL,*q=NULL; char a[MAXSize]; int i=0,n=0; cin>>a; newnode=new sqstack; newnode->data='='; newnode->next=L1; L1=newnode; while(1) { if(a[i]!='('&&a[i]!='+'&&a[i]!='-'&&a[i]!='*'&&a[i]!='/'&&a[i]!=')'&&a[i]!='(') { while(a[i]>='0'&&a[i]<='9') { newnode=new sqstack; newnode->data=a[i]; newnode->next=L2; L2=newnode; i++; } newnode=new sqstack; newnode->data='#'; newnode->next=L2; L2=newnode; } while(1) { if(neishu(L1->data)>waishu(a[i])) { p=L1; L1=L1->next; p->next=L2; L2=p; break; } if(neishu(L1->data)<waishu(a[i])) { if(a[i]=='\0') { while(L1->data!='=') { p=L1; L1=L1->next; p->next=L2; L2=p; }break; } else { newnode=new sqstack; newnode->data=a[i]; newnode->next=L1; L1=newnode; } i++; break; } if(neishu(L1->data)==waishu(a[i])) { p=L1; L1=L1->next; delete p; i++; } if(L1->data=='=')break; } if(a[i]=='\0')break; } while(L2->next!=NULL) { p=L2; L2=L2->next; p->next=L; L=p; } } void jisuan(struct sqstack *L) { struct sqstack *p; int i=0,j=0,k=0,m=0,n=0,a[MAXSize]; while(L->next!=NULL) { switch(L->data) { case '+': a[j-2]=a[j-1]+a[j-2];j--;break; case '-': a[j-2]=a[j-2]+a[j-1];j--;break; case '*': a[j-2]=a[j-1]*a[j-2];j--;break; case '/': a[j-2]=a[j-2]/a[j-1];j--;break; default: if(L->data!='#') i=i*10+(L->data-48); else { a[j]=i; i=0; j++; } break; } p=L; L=L->next; delete p; } printf("%d",a[j-1]); } ``` 测试数据 3 3+5*8 (3+5)*8 (23+34*45/(5+6+7))
代码有问题,求大神。
![图片说明](https://img-ask.csdn.net/upload/201703/30/1490880424_2788.png) ``` #include<stdio.h> #include<malloc.h> #include<iostream> using namespace std; #define MAXSize 10000 struct { char data; int n; }nei[]={{'=',0},{'(',1},{'+',3},{'-',3},{'*',5},{'/',5},{')',6}}, wai[]={{'=',0},{'(',6},{'+',2},{'-',2},{'*',4},{'/',4},{')',1}}; struct sqstack { char data; struct sqstack *next; }; void initstack(struct sqstack* &); void push(struct sqstack* &,struct sqstack *,struct sqstack *); void jisuan(struct sqstack *); int waishu(char ); int main() { struct sqstack *L1,*L,*L2; int i,n; initstack(L); initstack(L1); initstack(L2); scanf("%d",&n); for(i=0;i<n;i++) { L->next=NULL; push(L,L1,L2); jisuan(L); if(i!=n-1)printf("\n"); } return 0; } void initstack(struct sqstack* &L) { L=new sqstack; L->next=NULL; } int neishu(char c) { int i=0; for(i=0;i<7;i++) { if(nei[i].data==c) return nei[i].n; } } int waishu(char c) { int i=0; for(i=0;i<7;i++) { if(wai[i].data==c) return wai[i].n; } } void push(struct sqstack* &L,struct sqstack *L1,struct sqstack *L2) { struct sqstack *newnode=NULL,*p=NULL,*q=NULL; char a[MAXSize]; int i=0,n=0; cin>>a; newnode=new sqstack; newnode->data='='; newnode->next=L1; L1=newnode; while(1) { if(a[i]!='('&&a[i]!='+'&&a[i]!='-'&&a[i]!='*'&&a[i]!='/'&&a[i]!=')'&&a[i]!='(') { while(a[i]>='0'&&a[i]<='9') { newnode=new sqstack; newnode->data=a[i]; newnode->next=L2; L2=newnode; i++; } newnode=new sqstack; newnode->data='#'; newnode->next=L2; L2=newnode; } while(1) { if(neishu(L1->data)>waishu(a[i])) { p=L1; L1=L1->next; p->next=L2; L2=p; break; } if(neishu(L1->data)<waishu(a[i])) { if(a[i]=='\0') { while(L1->data!='=') { p=L1; L1=L1->next; p->next=L2; L2=p; }break; } else { newnode=new sqstack; newnode->data=a[i]; newnode->next=L1; L1=newnode; } i++; break; } if(neishu(L1->data)==waishu(a[i])) { p=L1; L1=L1->next; delete p; i++; } if(L1->data=='=')break; } if(a[i]=='\0')break; } while(L2->next!=NULL) { p=L2; L2=L2->next; p->next=L; L=p; } } void jisuan(struct sqstack *L) { struct sqstack *p; int i=0,j=0,k=0,m=0,n=0,a[MAXSize]; while(L->next!=NULL) { switch(L->data) { case '+': a[j-2]=a[j-1]+a[j-2];j--;break; case '-': a[j-2]=a[j-2]+a[j-1];j--;break; case '*': a[j-2]=a[j-1]*a[j-2];j--;break; case '/': a[j-2]=a[j-2]/a[j-1];j--;break; default: if(L->data!='#') i=i*10+(L->data-48); else { a[j]=i; i=0; j++; } break; } p=L; L=L->next; delete p; } printf("%d",a[j-1]); } ``` 3 3+5*8 (3+5)*8 (23+34*45/(5+6+7))
我的选择难度怎么赋值给切割函数啊
``` ``` var contentDiv = document.getElementById("content"); var ofrag; var oldimgs = []; //旧数组 var newimgs = []; //新数组 var imgItems = []; // 存放DIV var pos = []; // 存放图片位置 var minindex = 5; var near; var xxx; var xxx1; function getone(num){ //选择难度 if(num==3){ row=col=3 xxx=3; //xxx代表 行列数 xxx1=200; ///xxx1 代表要乘的数 } else if(num==4){ row=col=4 xxx=4; xxx1=150; } else if(num==6){ row=col=6 xxx=6 xxx1=100; } } function init(row,col){ //为oldimgs赋值 for(var i=1;i<=row*col;i++){ oldimgs.push(i); } newimgs = oldimgs.slice(0);//赋值新数组 ofrag = document.createDocumentFragment(); //文档碎片 for(var i=0;i<row * col;i++){ //i-----0-8 i%3 0%3=0 1%3=1 2%3=2 3%3=0 // 0/3=0 1/3=0 2/3=0 4/3=1 /* 3.3 200 4.4 150 6.6 100 */ var x = -((i%xxx)*xxx1); //0 200 400 进行循环 var y = -(Math.floor((i/xxx))*xxx1); //0 0 200 var div = document.createElement("div"); div.style.cursor = "move"; div.style.backgroundImage = "url(pintu.jpeg)"; div.style.backgroundRepeat = "no-repeat"; div.style.float = "left"; div.style.height = "xxx1px"; div.style.width = "xxx1px"; div.style.backgroundPosition = ""+ x +"px "+y+"px"; imgItems.push(div); ofrag.appendChild(div); } contentDiv.appendChild(ofrag); getone(3); } init(xxx,xxx); document.getElementById("start").onclick = function(){ startGame(); //开始游戏 } function startGame(){ //打乱图片位置 newimgs.sort(function(a,b){ return Math.random() > 0.5 ?1: -1; }) //记住之前图片的位置 for(i=0;i<row*col;i++){ pos[i] = [imgItems[i].offsetLeft,imgItems[i].offsetTop]; } for(var i =0; i<row*col;i++){ var num = newimgs[i]-1; var x = -(num%xxx)*xxx1; var y = -Math.floor((num/xxx))*xxx1; imgItems[i].style.left = pos[i][0] + "px"; imgItems[i].style.top = pos[i][1] + "px"; imgItems[i].style.position = "absolute"; imgItems[i].style.backgroundPosition = ""+x+"px "+y+"px "; imgItems[i].index = i; //设置访问的下标 imgItems[i].onmousedown = dragImage; } } function cheakNear(dom1,dom2){ //判断是否重合到一起了 //dom1是我们拖动的DIV dom2是我们循环的每一个DIV if(dom1==dom2){ return; } var l1 = dom1.offsetLeft; var t1 = dom1.offsetTop; var r1 = dom1.offsetWidth +l1; var b1 = dom1.offsetHeight + t1; var l2 = dom2.offsetLeft; var t2 = dom2.offsetTop; var r2 = dom2.offsetWidth +l1; var b2 = dom2.offsetHeight + t1; // 如何去判断我拖动的图片覆盖到下面的图片了 if(l1 > r2 || t1 > b2 || r1 < l2 || b1 < t2){ //一定没有覆盖到图片 别忘了练习 return false; } else{ return true; } } function dis(dom1,dom2){ var l1 = dom1.offsetLeft - dom2.offsetLeft; var l2 = dom1.offsetTop - dom2.offsetTop; return Math.sqrt(l1*l1+l2*l2); //不能为负数 } function findnear(dom){ var index_nei = -1; var imin = 999999; for(var i=0;i<row*col;i++){ imgItems[i].className = ""; if(cheakNear(dom,imgItems[i])){ var dx = dis(dom,imgItems[i]); if(imin>dx){ imin = dx; index_nei = i; } } } if(index_nei==-1){ return null; } else{ return imgItems[index_nei]; } } var disX,disY,l,t; function dragImage(event){ //确定我们点的是哪个DIV var dom = this; minindex++; dom.style.zIndex = minindex; disX = event.clientX - dom.offsetLeft; //X坐标距离差 disY = event.clientY- dom.offsetTop; document.onmousemove = function(event){ l = event.clientX - disX; //鼠标拖动图片 near = findnear(dom); if(near){ //如果是一个真实的对象 返回真 ,反之。 near.className= "active"; } dom.style.left = l+"px"; dom.style.top = t+"px"; } document.onmouseup = function(){ //鼠标释放 //move函数代表着图片移动回去 if(near){ near.className = ""; move(dom,pos[near.index][0],pos[near.index][1]); move(near,pos[dom.index][0],pos[dom.index][1]); // 交换一下index var temp = 0; temp = near.index; near.index = dom.index; dom.index = temp; for(var i =0; i<row*col;i++){ oldimgs[i] = imgItems[i].index+1; } if(success()){ gameOver(); } } else{ move(dom,pos[dom.index][0],pos[dom.index][1]); //move 函数 } //释放资源 document.onmousemove = null; document.onmouseup = null; } } //拼图结束 function success(){ for(var i=0;i<row*col-1;i++){ if(newimgs[i]!=oldimgs[i]){ return false; } } return true; } //游戏结束 function gameOver(){ var successDIV = document.createElement("div"); var inner_p = document.createElement("p"); var t = 2; var timer ; successDIV.style.cssText = "position:absolute;z-index:99999;top:50%;width:100%;text-align:center;font-size:70px;color:red;"; successDIV.innerHTML = "good job !!"; successDIV.appendChild(inner_p); contentDiv.appendChild(successDIV); function timerClear(){ inner_p.innerHTML = t--; if(t<=0){ clearInterval(timer); window.location.reload(); //刷新本页面 return; } timer=setTimeout(function(){ timerClear(); },1000); } timerClear(); } //拖动后不交换位置回到原位置 function move(dom,left,top){ //left和top是原始数据 clearInterval(dom.timer); dom.timer = setInterval(function(){ var stop_index = false;// 标志,停止移动 //移动到的新数据 var i_left = parseInt(dom.style.left); var i_top = parseInt(dom.style.top); if(left!=i_left || top!=i_top){ // i_speed 一般代表速度值 var i_speed_left = (left - i_left)/5; var i_speed_top = (top - i_top)/5; // Math.ceil 吐过这个值是整数 会将小数部分进一, 如果是负数则会舍弃小数 i_speed_left = i_speed_left > 0 ? Math.ceil(i_speed_left) : Math.floor(i_speed_left); i_speed_top = i_speed_top > 0 ? Math.ceil(i_speed_top) : Math.floor(i_speed_top); dom.style.left = (i_left + i_speed_left) + "px"; dom.style.top = (i_top + i_speed_top) + "px"; } else{ stop_index = true; } if(stop_index){ clearInterval(dom.timer); } },10); }
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小人工智障。 思路可以运用在不同地方,主要介绍的是思路。
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
阿里面试官问我:如何设计秒杀系统?我的回答让他比起大拇指
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图和个人联系方式,欢迎Star和指教 前言 Redis在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在Redis的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了...
C语言魔塔游戏
很早就很想写这个,今天终于写完了。 游戏截图: 编译环境: VS2017 游戏需要一些图片,如果有想要的或者对游戏有什么看法的可以加我的QQ 2985486630 讨论,如果暂时没有回应,可以在博客下方留言,到时候我会看到。 下面我来介绍一下游戏的主要功能和实现方式 首先是玩家的定义,使用结构体,这个名字是可以自己改变的 struct gamerole { char n...
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
Android性能优化(4):UI渲染机制以及优化
文章目录1. 渲染机制分析1.1 渲染机制1.2 卡顿现象1.3 内存抖动2. 渲染优化方式2.1 过度绘制优化2.1.1 Show GPU overdraw2.1.2 Profile GPU Rendering2.2 卡顿优化2.2.1 SysTrace2.2.2 TraceView 在从Android 6.0源码的角度剖析View的绘制原理一文中,我们了解到View的绘制流程有三个步骤,即m...
微服务中的Kafka与Micronaut
今天,我们将通过Apache Kafka主题构建一些彼此异步通信的微服务。我们使用Micronaut框架,它为与Kafka集成提供专门的库。让我们简要介绍一下示例系统的体系结构。我们有四个微型服务:订单服务,行程服务,司机服务和乘客服务。这些应用程序的实现非常简单。它们都有内存存储,并连接到同一个Kafka实例。 我们系统的主要目标是为客户安排行程。订单服务应用程序还充当网关。它接收来自客户的请求...
致 Python 初学者们!
作者| 许向武 责编 | 屠敏 出品 | CSDN 博客 前言 在 Python 进阶的过程中,相信很多同学应该大致上学习了很多 Python 的基础知识,也正在努力成长。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 Python 这门编程语言,从2009年开始单一使用 Python 应对所有的开发工作,直至今...
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观...
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外...
字节跳动面试官这样问消息队列:分布式事务、重复消费、顺序消费,我整理了一下
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip installselenium -ihttps://pypi.tuna.tsinghua.edu.cn/simple/ ...
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca...
SpringBoot2.x系列教程(三十六)SpringBoot之Tomcat配置
Spring Boot默认内嵌的Tomcat为Servlet容器,关于Tomcat的所有属性都在ServerProperties配置类中。同时,也可以实现一些接口来自定义内嵌Servlet容器和内嵌Tomcat等的配置。 关于此配置,网络上有大量的资料,但都是基于SpringBoot1.5.x版本,并不适合当前最新版本。本文将带大家了解一下最新版本的使用。 ServerProperties的部分源...
Python绘图,圣诞树,花,爱心 | Turtle篇
每周每日,分享Python实战代码,入门资料,进阶资料,基础语法,爬虫,数据分析,web网站,机器学习,深度学习等等。 公众号回复【进群】沟通交流吧,QQ扫码进群学习吧 微信群 QQ群 1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle()...
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东...
破14亿,Python分析我国存在哪些人口危机!
一、背景 二、爬取数据 三、数据分析 1、总人口 2、男女人口比例 3、人口城镇化 4、人口增长率 5、人口老化(抚养比) 6、各省人口 7、世界人口 四、遇到的问题 遇到的问题 1、数据分页,需要获取从1949-2018年数据,观察到有近20年参数:LAST20,由此推测获取近70年的参数可设置为:LAST70 2、2019年数据没有放上去,可以手动添加上去 3、将数据进行 行列转换 4、列名...
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o...
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ...... ...
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。 再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。 下文是原回答,希望能对你能有所启发。 如果我说,这个世界上人真的分三六九等,...
2020年全新Java学习路线图,含配套视频,学完即为中级Java程序员!!
新的一年来临,突如其来的疫情打破了平静的生活! 在家的你是否很无聊,如果无聊就来学习吧! 世上只有一种投资只赚不赔,那就是学习!!! 传智播客于2020年升级了Java学习线路图,硬核升级,免费放送! 学完你就是中级程序员,能更快一步找到工作! 一、Java基础 JavaSE基础是Java中级程序员的起点,是帮助你从小白到懂得编程的必经之路。 在Java基础板块中有6个子模块的学...
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合...
爬取薅羊毛网站百度云资源
这是疫情期间无聊做的爬虫, 去获取暂时用不上的教程 import threading import time import pandas as pd import requests import re from threading import Thread, Lock # import urllib.request as request # req=urllib.request.Requ...
如何优雅地打印一个Java对象?
你好呀,我是沉默王二,一个和黄家驹一样身高,和刘德华一样颜值的程序员。虽然已经写了十多年的 Java 代码,但仍然觉得自己是个菜鸟(请允许我惭愧一下)。 在一个月黑风高的夜晚,我思前想后,觉得再也不能这么蹉跎下去了。于是痛下决心,准备通过输出的方式倒逼输入,以此来修炼自己的内功,从而进阶成为一名真正意义上的大神。与此同时,希望这些文章能够帮助到更多的读者,让大家在学习的路上不再寂寞、空虚和冷。 ...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名...
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计...
HTML5适合的情人节礼物有纪念日期功能
前言 利用HTML5,css,js实现爱心树 以及 纪念日期的功能 网页有播放音乐功能 以及打字倾诉感情的画面,非常适合情人节送给女朋友 具体的HTML代码 具体只要修改代码里面的男某某和女某某 文字段也可自行修改,还有代码下半部分的JS代码需要修改一下起始日期 注意月份为0~11月 也就是月份需要减一。 当然只有一部分HTML和JS代码不够运行的,文章最下面还附加了完整代码的下载地址 &lt;!...
Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕(三)发送篇
今天介绍的项目是使用 Itchat 发送统计报告 项目功能设计: 定时爬取疫情数据存入Mysql 进行数据分析制作疫情报告 使用itchat给亲人朋友发送分析报告 基于Django做数据屏幕 使用Tableau做数据分析 来看看最终效果 目前已经完成,预计2月12日前更新 使用 itchat 发送数据统计报告 itchat 是一个基于 web微信的一个框架,但微信官方并不允许使用这...
python沙箱逃逸
沙箱逃逸是CTF和实际场景中经常遇到的一种情况。需要利用python的特性来实现逃逸。本文详细介绍了关于python逃逸的基础以及一些构造payload方法,并且附加习题提供练习。
作为程序员的我,大学四年一直自学,全靠这些实用工具和学习网站!
我本人因为高中沉迷于爱情,导致学业荒废,后来高考,毫无疑问进入了一所普普通通的大学,实在惭愧???? 我又是那么好强,现在学历不行,没办法改变的事情了,所以,进入大学开始,我就下定决心,一定要让自己掌握更多的技能,尤其选择了计算机这个行业,一定要多学习技术。 在进入大学学习不久后,我就认清了一个现实:我这个大学的整体教学质量和学习风气,真的一言难尽,懂的人自然知道怎么回事? 怎么办?我该如何更好的提升自...
新来个技术总监,禁止我们使用Lombok!
我有个学弟,在一家小型互联网公司做Java后端开发,最近他们公司新来了一个技术总监,这位技术总监对技术细节很看重,一来公司之后就推出了很多"政策",比如定义了很多开发规范、日志规范、甚至是要求大家统一使用某一款IDE。 但是这些都不是我这个学弟和我吐槽的点,他真正和我吐槽的是,他很不能理解,这位新来的技术总监竟然禁止公司内部所有开发使用Lombok。但是又没给出十分明确的,可以让人信服的理由。 于...
教你如何编写第一个简单的爬虫
很多人知道爬虫,也很想利用爬虫去爬取自己想要的数据,那么爬虫到底怎么用呢?今天就教大家编写一个简单的爬虫。 下面以爬取笔者的个人博客网站为例获取第一篇文章的标题名称,教大家学会一个简单的爬虫。 第一步:获取页面 #!/usr/bin/python # coding: utf-8 import requests #引入包requests link = "http://www.santostang....
前端JS初级面试题二 (。•ˇ‸ˇ•。)老铁们!快来瞧瞧自己都会了么
1. 传统事件绑定和符合W3C标准的事件绑定有什么区别? 传统事件绑定 &lt;div onclick=""&gt;123&lt;/div&gt; div1.onclick = function(){}; &lt;button onmouseover=""&gt;&lt;/button&gt; 注意: 如果给同一个元素绑定了两次或多次相同类型的事件,那么后面的绑定会覆盖前面的绑定 (不支持DOM事...
情人节到了,适合程序员表白的情话【保你脱单】
谁说我们程序员不浪漫,这些情话只有程序员能看懂
MySQL explain命令详解
使用explain + sql语句可以得到该条sql语句的执行计划,具体信息如下 下面将依次介绍每个字段的含义 id id表示在多表查询时,表的执行顺序,它是一组数字序列号,表示查询中执行select子句或操作表的顺序,其取值分为以下三种情况 1.id相同,表示表的执行顺序由上至下 上例中,表示该sql语句执行时对三张表的查询顺序是先查询t1,再查询t3,最后查询t3 2....
相关热词 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数 c#日期精确到分钟 c#自定义异常必须继承 c#查表并返回值 c# 动态 表达式树 c# 监控方法耗时 c# listbox c#chart显示滚动条
立即提问