aardio利用sunny中间件实现只显示网页部分内容
????????前兩天有個(gè)朋友有個(gè)需求,在利用aardio開(kāi)發(fā)的軟件打開(kāi)一個(gè)網(wǎng)站時(shí),首頁(yè)只想顯示部分內(nèi)容,其他信息不顯示。aardio的web.form有一個(gè)顯示部分網(wǎng)頁(yè)的范例,可以實(shí)現(xiàn)需求,但是用這種方式打開(kāi)的網(wǎng)頁(yè),后面再打開(kāi)的網(wǎng)頁(yè)也只能顯示一部分。突然想到光慶封裝的sunny庫(kù)?(下載地址:光慶·程序·在線)有一個(gè)例子是替換網(wǎng)頁(yè)中圖片,由此聯(lián)想,可以網(wǎng)頁(yè)內(nèi)容也可以修改。經(jīng)征得光慶同意,下面以光慶·程序·在線網(wǎng)站為例介紹實(shí)現(xiàn)過(guò)程。
光慶·程序·在線首頁(yè)內(nèi)容如下圖:
?現(xiàn)在想要打開(kāi)網(wǎng)頁(yè)時(shí)只顯示下圖紅框中的內(nèi)容及底部翻頁(yè)內(nèi)容和版權(quán)信息:
實(shí)現(xiàn)步驟:1、獲取首頁(yè)網(wǎng)頁(yè)源碼,去除不想顯示的內(nèi)容,然后作為要顯示的內(nèi)容保存,這里注意把編碼改為utf-8格式,否則會(huì)現(xiàn)出亂碼。
? ? ? ? ? ? ? ? ? 2、利用sunny庫(kù)獲取請(qǐng)求光慶·程序·在線首頁(yè)返回的網(wǎng)頁(yè)源碼;
? ? ? ? ? ? ? ? ? 3、用sunny庫(kù)的setData設(shè)置返回的數(shù)據(jù)為第一步保存的網(wǎng)頁(yè)源碼。
實(shí)現(xiàn)效果如下(下面部分沒(méi)有有了,但其他效果和官網(wǎng)一樣):
?下面上代碼:
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio利用sunny中間件實(shí)現(xiàn)攔截并修改網(wǎng)頁(yè)內(nèi)容";right=1025;bottom=680;border="thin";maximize=1) winform.add() /*}}*/import godking.sunny; var sunny=godking.sunny(); import web.view; var wb = web.view(winform,"c:\user1",`--proxy-server="socks://127.0.0.1:2021"`);sunny.callback_http = function(winform,id,msgid,msgtype,mod,url,pid,notice,err){// 注意:1、回調(diào)函數(shù)為線程函數(shù);2、要重新引用godking.sunnyimport godking.sunny import web.json; var response = godking.sunny.httpResponse(msgid);if msgtype==godking.sunny.msgType.http_response and url="http://chengxu.online/" {//data為目標(biāo)網(wǎng)頁(yè)代碼(去除不想要的內(nèi)容后的代碼)var data=/***<html><head><title>光慶·程序·在線</title><link rel="shortcut icon" href="/favicon.ico"><link rel="bookmark" href="/favicon.ico"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta content="all" name="Robots"><meta content="MSHTML 6.00.3790.2706" name="GENERATOR"><link href="images/Style.css" type="text/css" rel="stylesheet"></head><body bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0"><table class="toptable" height="27" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"><tbody><tr><td height="100"><img src="images/banner.gif"></td></tr></tbody></table><style type="text/css">table.change:hover{background-color:#eeeeee}</style><script type="text/javascript">function rowClick (fileurl) {window.open(fileurl);}</script><table width="100%" align="center"><tbody><tr><td style="WIDTH: 200px; HEIGHT: 21px; TEXT-ALIGN: center" align="left" valign="top"><table height="100%" width="200px"><tbody><tr height="36px"><td bgcolor="#3399ff" style="FONT-SIZE: 14px;FONT-WEIGHT: bold; COLOR: white; HEIGHT: 25px; TEXT-ALIGN: center; TEXT-DECORATION: none">首頁(yè) 》 網(wǎng)站公告</td></tr><tr><td class="table" style="FONT-SIZE: 14px;padding:10;" width="200px" valign="top" height="100%">1、本站主要用來(lái)發(fā)布本人[光慶]原創(chuàng)的軟件作品。<br>2、同時(shí),搜集了一些比較好用的軟件。特別是一些綠化的、無(wú)廣告的軟件,值得珍藏。<br>3、用來(lái)推薦一些比較好的軟件下載站。<br>4、承接軟件定做業(yè)務(wù)。<p>業(yè)務(wù)QQ:17950677<br>微信號(hào):godking888</p></td></tr></tbody></table></td><td style="WIDTH:100%; HEIGHT: 21px" align="center" valign="top"><table style="WIDTH: 100%; HEIGHT: 182px"><tbody><form id="form1" name="form1" method="post" action="index.asp"></form><tr height="36px"><td colspan="3" valign="middle" bgcolor="#3399ff" style="FONT-SIZE: 14px;FONT-WEIGHT: bold; COLOR: white; TEXT-DECORATION: none"> 文件類型:<select name="ClassID" id="ClassID" style="FONT-SIZE: 14px;"><option value="0">全部類型</option><option value="11">aardio資源</option><option value="4">裝機(jī)工具</option><option value="5">應(yīng)用軟件</option><option value="10">精品網(wǎng)站</option><option value="1">其它資料</option><option value="12">精彩文章</option></select> 操作系統(tǒng):<select name="System" id="System" style="FONT-SIZE: 14px;"><option value="">全部系統(tǒng)</option><option value="Win 32位">Win 32位</option><option value="Win 64位">Win 64位</option><option value="安卓系統(tǒng)">安卓系統(tǒng)</option><option value="網(wǎng)址">網(wǎng)址</option><option value="其他">其他</option></select> 關(guān)鍵字:<input name="keyword" type="text" id="keyword" size="20" value=""> <input type="submit" name="Submit" value="搜索"></td></tr><tr><td class="table" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="3" style="border-collapse: collapse;"><tbody><tr height="150"><td width="33%" height="80px"><table class="change" cellspacing="0" cellpadding="0" style="border:0px solid #f55901; border-collapse: collapse;background: #eeeeee;" width="100%" height="100%"><tbody><tr style="border-bottom: 0px solid #dddddd;"><td colspan="2" style="padding: 0 0 0 10; height:30px; font-size:18px; vertical-align: middle; background: #eeeeee;"><font style="background: red; font-size:14px; color: white; padding: 3 5; border-radius: 3px;">置頂</font><font style="font-size:18px; font-family: Microsoft YaHei;">aardio資源下載</font></td><td style="cursor:pointer; height: 30px; width: 80px; vertical-align: middle; background: #f55901;"><img onclick="rowClick('https://wws.lanzoui.com/b026gmeta')" src="images/view_btn.gif"> </td></tr><tr><td style="vertical-align: top; padding: 10px; width: 80px; "><div style="padding: 3px; width: 80px; height: 80px; overflow: hidden; border: 1px solid #BBBBBB; border-radius: 13px;"><img style="display:block; border-radius: 10px;" width="80" height="80" src="UploadPic/202110041531443238.png"></div></td><td height="100%" colspan="2" style="vertical-align: top; padding: 9px;"><p style="font-size:12px; color:#666666;">aardio資源 / Win 32位 / 0 Byte<br>本人編寫(xiě)的aardio庫(kù)等資源文件下載。使用方法可以參考本人CSDN博客,一般都有相關(guān)文章。<font color="red">瀏覽密碼:123</font><br></p></td></tr></tbody></table></td><td width="33%" height="80px"><table class="change" cellspacing="0" cellpadding="0" style="border:0px solid #f55901; border-collapse: collapse;background: #eeeeee;" width="100%" height="100%"><tbody><tr style="border-bottom: 0px solid #dddddd;"><td colspan="2" style="padding: 0 0 0 10; height:30px; font-size:18px; vertical-align: middle; background: #eeeeee;"><font style="background: red; font-size:14px; color: white; padding: 3 5; border-radius: 3px;">置頂</font><font style="font-size:18px; font-family: Microsoft YaHei;">CSDN光慶的學(xué)習(xí)筆記</font></td><td style="cursor:pointer; height: 30px; width: 80px; vertical-align: middle; background: #f55901;"><img onclick="rowClick('https://blog.csdn.net/sdlgq')" src="images/view_btn.gif"> </td></tr><tr><td style="vertical-align: top; padding: 10px; width: 80px; "><div style="padding: 3px; width: 80px; height: 80px; overflow: hidden; border: 1px solid #BBBBBB; border-radius: 13px;"><img style="display:block; border-radius: 10px;" width="80" height="80" src="UploadPic/202108101503325112.png"></div></td><td height="100%" colspan="2" style="vertical-align: top; padding: 9px;"><p style="font-size:12px; color:#666666;">精品網(wǎng)站 / 網(wǎng)址 / 0 Byte<br>CSDN光慶的學(xué)習(xí)筆記,用來(lái)記錄站長(zhǎng)學(xué)習(xí)中積累的知識(shí)點(diǎn)。<br></p></td></tr></tbody></table></td><td width="33%" height="80px"><table class="change" cellspacing="0" cellpadding="0" style="border:0px solid #1e90ff; border-collapse: collapse;background: #eeeeee;" width="100%" height="100%"><tbody><tr style="border-bottom: 0px solid #dddddd;"><td colspan="2" style="padding: 0 0 0 10; height:30px; font-size:18px; vertical-align: middle; background: #eeeeee;"><font style="background: #f55901; font-size:14px; color: white; padding: 3 5; border-radius: 3px;">原創(chuàng)</font><font style="font-size:18px; font-family: Microsoft YaHei;">考勤管理系統(tǒng)(單機(jī)版)</font></td><td style="cursor:pointer; height: 30px; width: 80px; vertical-align: middle; background: #1e90ff;"><img onclick="rowClick('https://wwr.lanzoui.com/iLQ2Hsmlebg')" src="images/download_btn.gif"> </td></tr><tr><td style="vertical-align: top; padding: 10px; width: 80px; "><div style="padding: 3px; width: 80px; height: 80px; overflow: hidden; border: 1px solid #BBBBBB; border-radius: 13px;"><img style="display:block; border-radius: 10px;" width="80" height="80" src="UploadPic/202108141700586833.png"></div></td><td height="100%" colspan="2" style="vertical-align: top; padding: 9px;"><p style="font-size:12px; color:#666666;">應(yīng)用軟件 / Win 32位 / 943 KB<br>考勤管理系統(tǒng),登記員工每日考勤,含早班、白班、晚班、加班,自動(dòng)生成每日考勤表,可統(tǒng)計(jì)每班簽到人數(shù)、查看每個(gè)員工的考勤情況,實(shí)時(shí)查看欠班天數(shù)。默認(rèn)登錄授權(quán)密碼:123。<br>密碼:6kok<br></p></td></tr></tbody></table></td></tr><tr height="150"><td width="33%" height="80px"><table class="change" cellspacing="0" cellpadding="0" style="border:0px solid #1e90ff; border-collapse: collapse;background: #eeeeee;" width="100%" height="100%"><tbody><tr style="border-bottom: 0px solid #dddddd;"><td colspan="2" style="padding: 0 0 0 10; height:30px; font-size:18px; vertical-align: middle; background: #eeeeee;"><font style="background: #f55901; font-size:14px; color: white; padding: 3 5; border-radius: 3px;">原創(chuàng)</font><font style="font-size:18px; font-family: Microsoft YaHei;">中文打字練習(xí)</font></td><td style="cursor:pointer; height: 30px; width: 80px; vertical-align: middle; background: #1e90ff;"><img onclick="rowClick('https://wwr.lanzoui.com/io8qpsmksdg')" src="images/download_btn.gif"> </td></tr><tr><td style="vertical-align: top; padding: 10px; width: 80px; "><div style="padding: 3px; width: 80px; height: 80px; overflow: hidden; border: 1px solid #BBBBBB; border-radius: 13px;"><img style="display:block; border-radius: 10px;" width="80" height="80" src="UploadPic/202108141648393895.png"></div></td><td height="100%" colspan="2" style="vertical-align: top; padding: 9px;"><p style="font-size:12px; color:#666666;">應(yīng)用軟件 / Win 32位 / 420 KB<br>中文練習(xí)工具,練習(xí)中文輸入速度,提升中文輸入能力。非常適合漢字錄入人員練習(xí)使用。<br>密碼:dw7u<br></p></td></tr></tbody></table></td><td width="33%" height="80px"><table class="change" cellspacing="0" cellpadding="0" style="border:0px solid #1e90ff; border-collapse: collapse;background: #eeeeee;" width="100%" height="100%"><tbody><tr style="border-bottom: 0px solid #dddddd;"><td colspan="2" style="padding: 0 0 0 10; height:30px; font-size:18px; vertical-align: middle; background: #eeeeee;"><font style="background: #f55901; font-size:14px; color: white; padding: 3 5; border-radius: 3px;">原創(chuàng)</font><font style="font-size:18px; font-family: Microsoft YaHei;">小鍵盤(pán)練習(xí)</font></td><td style="cursor:pointer; height: 30px; width: 80px; vertical-align: middle; background: #1e90ff;"><img onclick="rowClick('https://wwr.lanzoui.com/iDK54smk9dc')" src="images/download_btn.gif"> </td></tr><tr><td style="vertical-align: top; padding: 10px; width: 80px; "><div style="padding: 3px; width: 80px; height: 80px; overflow: hidden; border: 1px solid #BBBBBB; border-radius: 13px;"><img style="display:block; border-radius: 10px;" width="80" height="80" src="UploadPic/202108141636041668.png"></div></td><td height="100%" colspan="2" style="vertical-align: top; padding: 9px;"><p style="font-size:12px; color:#666666;">應(yīng)用軟件 / Win 32位 / 465.5 KB<br>小鍵盤(pán)練習(xí)工具,練習(xí)小鍵盤(pán)輸入速度,提升數(shù)字輸入能力。非常適合柜臺(tái)收銀員練習(xí)使用。<br>密碼:3xok<br></p></td></tr></tbody></table></td><td width="33%" height="80px"><table class="change" cellspacing="0" cellpadding="0" style="border:0px solid #1e90ff; border-collapse: collapse;background: #eeeeee;" width="100%" height="100%"><tbody><tr style="border-bottom: 0px solid #dddddd;"><td colspan="2" style="padding: 0 0 0 10; height:30px; font-size:18px; vertical-align: middle; background: #eeeeee;"><font style="background: #f55901; font-size:14px; color: white; padding: 3 5; border-radius: 3px;">原創(chuàng)</font><font style="font-size:18px; font-family: Microsoft YaHei;">算鈔練習(xí)</font></td><td style="cursor:pointer; height: 30px; width: 80px; vertical-align: middle; background: #1e90ff;"><img onclick="rowClick('https://wwr.lanzoui.com/iow6dsmjxwj')" src="images/download_btn.gif"> </td></tr><tr><td style="vertical-align: top; padding: 10px; width: 80px; "><div style="padding: 3px; width: 80px; height: 80px; overflow: hidden; border: 1px solid #BBBBBB; border-radius: 13px;"><img style="display:block; border-radius: 10px;" width="80" height="80" src="UploadPic/202108141628166924.png"></div></td><td height="100%" colspan="2" style="vertical-align: top; padding: 9px;"><p style="font-size:12px; color:#666666;">應(yīng)用軟件 / Win 32位 / 496.5 KB<br>算鈔練習(xí)工具,練習(xí)手動(dòng)算鈔能力,給出鈔票面值和張數(shù),快速計(jì)算出金額總數(shù)。非常適合柜臺(tái)收銀員練習(xí)使用。<br>密碼:7cfw<br></p></td></tr></tbody></table></td></tr><tr height="150"><td width="33%" height="80px"> </td></tr><tr><td colspan="3"><table align="center"><tbody><tr><td>共 <b>68</b> 個(gè)文件 首頁(yè) 上一頁(yè) <a href="index.asp?ClassID=0&System=&keyword=&page=2">下一頁(yè)</a> <a href="index.asp?ClassID=0&System=&keyword=&page=5">尾頁(yè)</a> 頁(yè)次:<strong><font color="red">1</font>/5</strong>頁(yè) <b>15</b>個(gè)文件/頁(yè) 轉(zhuǎn)到:<select name="page" size="1" onchange="javascript:window.location='index.asp?ClassID=0&System=&keyword=&page='+this.options[this.selectedIndex].value;"><option value="1" selected="">第1頁(yè)</option><option value="2">第2頁(yè)</option><option value="3">第3頁(yè)</option><option value="4">第4頁(yè)</option><option value="5">第5頁(yè)</option></select></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr></tr></tbody></table><table width="100%" align="center" cellspacing="1" cellpadding="1" class="bottomtable bgcolor_1"><tbody><tr><td align="middle" colspan="3" rowspan="3" class="copyright_td">? CopyRight 2020-2028 Design By:光慶·程序·在線 QQ:17950677 微信:godking888 頁(yè)面執(zhí)行時(shí)間:0.07813 秒</td></tr><tr></tr><tr></tr></tbody></table></body></html>***/response.setData(data); //設(shè)置返回網(wǎng)頁(yè)內(nèi)容為自定義內(nèi)容 } }sunny.start(2021/*代理端口*/,false/*過(guò)濾正文*/,isGlobal/*全局代理*/,true/*禁止壓縮*/,winform/*傳遞窗口*/); wb.go("http://chengxu.online/"); //打開(kāi)目標(biāo)網(wǎng)站winform.onClose = function(hwnd,message,wParam,lParam){//關(guān)閉窗口時(shí)停止sunny攔截sunny.stop(); }winform.show(); win.loopMessage();總結(jié)
以上是生活随笔為你收集整理的aardio利用sunny中间件实现只显示网页部分内容的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: arduino 土壤温湿度传感器_怎样将
- 下一篇: 第二十九篇 -- 学习第五十六天打卡20