当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 搜索gb2312汉字在网上的频率

Javascript
js 判断 enter 事件
谷歌浏览器 insertCell与appendChild的区别
从JavaScript 到 JQuery (1)学习小结
JavaScript实现动态增加文件域表单
JavaScript DOM 添加事件
Javascript 跨域访问解决方案
检测是否已安装 .NET Framework 3.5的js脚本
JavaScript 获得选中文本内容的方法
Javascript 获取链接(url)参数的方法
javascript Ext JS 状态默认存储时间
动态为事件添加js代码示例
JSON扫盲帖 JSON.as类教程
JavaScript 全面解析各种浏览器网页中的JS 执行顺序
js实现权限树的更新权限时的全选全消功能
javascript Table 中2个列(TD)的交换实现代码
js表数据排序 sort table data
javascript css在IE和Firefox中区别分析
JAVASCRIPT IE 与 FF中兼容问题小结
判断多个元素(RADIO,CHECKBOX等)是否被选择的原理说明
csdn 批量接受好友邀请

Javascript 中的 搜索gb2312汉字在网上的频率


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 403 ::
收藏到网摘: n/a

<title>..:: gb2312freq version4 ::.. win2000server & ie6sp1 & cr1.2g & 128m</title>

0.<br>
<center><a href="javascript:window.location.reload()">Reload All</a></center>
<input id=inpu0 type=button value="Auto Run!" onclick=f_inpu0()>
<input id=inpu0a size=6>
to<input id=inpu0b size=7>
DELAY=<input id=inpu0c size=8 value=1000><br>
Start time<input id=inpu0d size=25>
End time<input id=inpu0e size=25><br>
Report per<input id=inpu0f size=8 value=1000>char
<input id=inpu0z type=button value="User Stop!!!" onclick=f_inpu0z()><br>

1.<br>
<input name=radi1 type=radio onclick=f_radi1()>CLEAR
<input name=radi1 type=radio onclick=f_radi1()>Get BG2312
<input name=radi1 type=radio onclick=f_radi1() checked>3755<br>
<textarea id=text1 style="width: 90%; height: 50%"></textarea><br>

2.<br>
<input id=inpu2 onclick=f_inpu2() type=button value="search 0-???">
<input id=inpu2a size=8>
URL=
<input id=inpu2b size=9>
<input id=inpu2c size=10 readonly>
<input id=inpu2d size=11>
<INPUT name=radi2 type=radio onclick=f_radi2() checked>baidu
<INPUT name=radi2 type=radio onclick=f_radi2()>google<br>
<iframe id=ifra2 src="about:" width=90% height=50%></iframe><br>

3.<br>
<input id=inpu3 onclick=f_inpu3();pagedown() type=button value="source">
between<input id=inpu3a>
and<input id=inpu3b>
=<input id=inpu3c><br>
<textarea id=text3 style="width: 90%; height: 50%"></textarea><br>

4.<br>
<input id=inpu4 onclick=f_inpu4();pageup() type=button value="result">
<input id=inpu4a><br>
<textarea id=text4 style="width: 90%; height: 50%"></textarea><br>

 

 

<script>
///////////////////////////// user function //////////////////////////////////
function f_inpu0()
{
  inpu0d.value=Date() //set start time
  inpu0e.value='' //set end time empty
  inpu2a.value=inpu0a.value //before search, set start char

  autorun() //run search
}
function autorun()
{
  if(Number(inpu0a.value)<Number(inpu0b.value)) //if OK continue Auto Run
  {
    inpu0e.value=Date() //set end time
    inpu0a.value++ //prepare for next char

    f_inpu2()
    f_inpu3()
    f_inpu4()

    setTimeout('autorun()',inpu0c.value) //delay for next Auto Run
  }
  else
  {
//alert(inpu0a.value+"\n"+inpu0b.value)
  }

  if(inpu0a.value%inpu0f.value==0) //if need give a report
  {
    report() //give a report
  }
}

function f_inpu0z()
{
  inpu0b.value=inpu0a.value //stop!!!
}

function f_radi1()
{
  if(radi1[0].checked==true)
  {
    inpu0a.value=0 //set autorun start
    inpu0b.value=0 //set autorun end
    text1.value=''
  }
  else if(radi1[1].checked==true) //if need 6763 of gb2312
  {
    inpu0a.value=0 //set autorun start
    inpu0b.value=6763 //set autorun end
    tmpstr=text0.value //get gb2312 full string
    tmpstr=tmpstr.substring(tmpstr.indexOf("01"),tmpstr.length) //del "...GB 2312-80"
    tmpstr=tmpstr.replace(/[^\u4e00-\u9fa5]/g,"") //del no GB2312
    text1.value=tmpstr //put string to text1
  }
  else if(radi1[2].checked==true) //if need 3755 of gb2312
  {
    inpu0a.value=0 //set autorun start
    inpu0b.value=3755 //set autorun end
    tmpstr=text0.value //get gb2312 full string
    tmpstr=tmpstr.substring(tmpstr.indexOf("01"),tmpstr.length) //del "...GB 2312-80"
    tmpstr=tmpstr.replace(/[^\u4e00-\u9fa5]/g,"") //del no GB2312
    text1.value=tmpstr //put string to text1
    text1.value=text1.value.substring(0,3755) //get the first 3755 char
  }
}

function f_inpu2()
{
  inpu2c.value=text1.value.charAt(inpu2a.value) //current char

  if(radi2[1].checked==true) //if google
  {
    inpu2c.value=encodeURIComponent(inpu2c.value) //change string to encode for google
  }

  tmpsrc = '<iframe id=ifra2 src="'
         + inpu2b.value
         + inpu2c.value
         + inpu2d.value
         + '"width=90%  height=50%></iframe>' //prepare the search char

  document.all.ifra2.outerHTML=tmpsrc //run search

  inpu2a.value++ //prepare next search
}

function f_radi2()
{
  if(radi2[0].checked==true) //if baidu
  {
    inpu2b.value="http://www1.baidu.com/baidu?word="
    inpu2c.value=""
    inpu2d.value=""
    inpu3a.value="百度为您找到相关网页约"
    inpu3b.value="篇,用时"
    inpu3c.value=""
  }
  else if(radi2[1].checked==true) //if google
  {
    inpu2b.value="http://www.google.com/search?hl=zh-CN&ie=UTF-8&oe=UTF-8&q="
    inpu2c.value=""
    inpu2d.value="&lr=lang_zh-CN"
    inpu3a.value="共有 <b>"
    inpu3b.value="</b> 项查询结果,这是第"
    inpu3c.value=""
  }
}

function f_inpu3()
{
  if(radi2[0].checked==true) //if baidu
  {
    text3.value=bytes2bstr(loadContent(document.getElementById("ifra2").src)) //put source
  }
  else if(radi2[1].checked==true) //if google
  {
    text3.value=loadUTF8(document.getElementById("ifra2").src) //the source of google is UTF-8
  }

  tmpstr=text3.value
  if(tmpstr.indexOf(inpu3a.value)>-1&&tmpstr.indexOf(inpu3b.value)>-1) //if found
  {
    tmpstr=tmpstr.substring(tmpstr.indexOf(inpu3a.value) + inpu3a.value.length,
                            tmpstr.indexOf(inpu3b.value)) //get useful source
  }
  else
  {
    tmpstr=":(" //if not found
  }
  inpu3c.value=tmpstr //write to inpu3c.value
}
function loadUTF8(strURL) //for google (used for "function f_inpu3()")
{
 var strContent = "";
 if (typeof strURL != "string" || strURL == "")return strContent;
 try
 {
  var oProxy = new ActiveXObject("Microsoft.XMLHTTP");
  
  oProxy["Open"]("GET", strURL, false);
  oProxy["Send"]();
  strContent = oProxy["responseText"]; //get Text html
///  strContent = oProxy["responseBody"]; //get Bin html, and then change2text
 }
 catch(e){status = e.description}
 return strContent;
}
function loadContent(strURL) //I get this code from a friend (used for "function f_inpu3()")
{
 var strContent = "";
 if (typeof strURL != "string" || strURL == "")return strContent;
 try
 {
  var oProxy = new ActiveXObject("Microsoft.XMLHTTP");
  
  oProxy["Open"]("GET", strURL, false);
  oProxy["Send"]();
///  strContent = oProxy["responseText"]; //get Text html
  strContent = oProxy["responseBody"]; //get Bin html, and then change2text
 }
 catch(e){status = e.description}
 return strContent;
}
function bytes2bstr(vin) //Have this code from a friend (used for "function f_inpu3()")
{
 var st = new ActiveXObject("adodb.stream")
 with (st){
  Type = 2 //var adTypeBinary = 1; var adTypeText = 2
  Open()
  WriteText(vin)
  Position = 0
  Charset = "GB2312"
  Position = 2
  return ReadText
 }
}

function f_inpu4()
{
  text4.value=text4.value+text1.value.charAt(inpu2a.value-1)+'\t'+inpu3c.value+'\n' //get current full result to text4
  text4.scrollTop=text4.scrollHeight //scroll down to bottom

  inpu4a.value=text4.value.split('\n').length-1 //totol line
}

function pagedown()
{
  document.body.scrollTop += document.body.clientHeight/2 //scroll down half screen
}

function pageup()
{
  document.body.scrollTop -= document.body.clientHeight //scroll up a screen
}

function report()
{
//  alert()
}
</script>


<script>
///////////////////////////// system function /////////////////////////////////
function window.onload()
{
  inpu2a.value=0 //set init is null
  f_radi1() //set default chars
  f_radi2() //set search engine
}
</script>

 

 

 

 


<textarea id=text0 style="visibility:hidden">
     中华人民共和国国家标准
    信息交换用汉字编码字符集
         基   本   集
          GB 2312-80


01 0 1 2 3 4 5 6 7 8 9
0     、 。 · ˉ ˇ ¨ 〃 々
1 — ~ ‖ … ‘ ’ “ ” 〔 〕
2 〈 〉 《 》 「 」 『 』 〖 〗
3 【 】 ± × ÷ ∶ ∧ ∨ ∑ ∏
4 ∪ ∩ ∈ ∷ √ ⊥ ∥ ∠ ⌒ ⊙
5 ∫ ∮ ≡ ≌ ≈ ∽ ∝ ≠ ≮ ≯
6 ≤ ≥ ∞ ∵ ∴ ♂ ♀ ° ′ ″
7 ℃ $ ¤ ¢ £ ‰ § № ☆ ★
8 ○ ● ◎ ◇ ◆ □ ■ △ ▲ ※
9 → ← ↑ ↓ 〓

02 0 1 2 3 4 5 6 7 8 9
0   ⅰ ⅱ ⅲ ⅳ ⅴ ⅵ ⅶ ⅷ ⅸ
1 ⅹ