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

Javascript
javascript 响应键盘特定按键(只响应数字键)
javascript indexOf方法、lastIndexOf 方法和substring 方法
javascript parseInt 函数分析(转)
javascript Split方法,indexOf方法、lastIndexOf 方法和substring 方法
JavaScript 面向对象入门精简篇
JS中==与===操作符的比较
JavaScript indexOf忽略大小写
dwr spring的集成实现代码
DWR Ext 加载数据
JavaScript 计算当天是本年本月的第几周
Js 获取当前日期时间及其它操作实现代码
javascript multibox 全选
JS array 数组详解
javascript 对象定义方法 简单易学
javascript 补零 函数集合
div scroll始终在最底部的实现代码
javascript eval()用法
javascript 打印页面代码
JAVASCRIPT THIS详解 面向对象
javascript 页面跳转方法集合

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


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