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

Javascript
JavaScript 序列化对象实现代码
替代window.event.srcElement效果的可兼容性的函数
div+css+js模拟tab切换效果 事件绑定 IE,firefox兼容
IE和Firefox下event事件杂谈
javascript option onclick事件ie解决方案 兼容ie,firefox
javascript demo 基本技巧
用js实现层随着内容大小动态渐变改变 推荐
JS 的应用开发初探(mootools)
JS 在数组插入字符的实现代码(可参考JavaScript splice() 方法)
JQuery Tips(4) 一些关于提高JQuery性能的Tips
jQuery 淡入淡出、展开收缩菜单实现代码
js控制div及网页相关属性的代码
javascript 翻页测试页(动态创建标签并自动翻页)
Js获取table当前tr行的值的代码
IE 上下滚动展示模仿Marquee机制
jQuery解决iframe高度自适应代码
jQuery 连续列表实现代码
利用jQuery的$.event.fix函数统一浏览器event事件处理
Javascript和Ajax中文乱码吐血版解决方案
js Firefox 加入收藏夹功能代码 兼容Firefox 和 IE

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 131 ::
收藏到网摘: 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 ⅹ