[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 zaqmlp 于 2019-8-22 14:15 编辑
  1. <# :
  2. cls
  3. @echo off
  4. mode con lines=3000
  5. cd /d "%~dp0"
  6. powershell -NoProfile -ExecutionPolicy bypass "&{[ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default)).Invoke()}"
  7. pause
  8. exit
  9. #>
  10. function gethtml($w){
  11.     $html='';
  12.     $url='http://dict.cn/'+$w;
  13.     $web=New-Object System.Net.WebClient;
  14.     $web.Encoding=[System.Text.Encoding]::UTF8;
  15.     for($i=1;$i -le 4;$i++){
  16.         try{
  17.             $html=$web.DownloadString($url);
  18.             break;
  19.         }catch{write-host ('获取网页内容第'+$i.toString()+'次失败')};
  20.     };
  21.     return $html;
  22. };
  23. function gethz($s){
  24.     $str='';
  25.     $str=[regex]::replace($s,'\\u([\da-z]{4})',{param($a);[char][Convert]::ToInt32($a.groups[1].value, 16)});
  26.     return $str;
  27. };
  28. $inputfile='单词列表.txt';
  29. $outfile='结果.txt';
  30. $min=5;
  31. [void][Reflection.Assembly]::LoadWithPartialName('System.Web');
  32. [System.Collections.ArrayList]$s=@();
  33. $text=[IO.File]::ReadAllLines($inputfile,[Text.Encoding]::Default);
  34. for($i=0;$i -lt $text.count;$i++){
  35.     write-host ('------------'+$text[$i]+'------------');
  36.     $content=gethtml $text[$i];
  37.     $m=[regex]::match($content,'<div .*?id="dict-chart-basic" data="([^"]+?)"');
  38.     if($m.success){
  39.         $js=[Web.HttpUtility]::UrlDecode($m.groups[1].value);
  40.         $tmp=(gethz $js) -replace '^\{|\}$','';
  41.         $mm=[regex]::matches($tmp,'\{([^\}]+?)\}');
  42.         [System.Collections.ArrayList]$t=@();
  43.         if($mm.count -ge 1){
  44.             foreach($it in $mm){
  45.                 $arr=$it.groups[1].value.split(':,', 4);
  46.                 if((1*$arr[1]) -ge $min){[void]$t.add($arr[3].Trim('"')+':'+$arr[1])};
  47.             };
  48.         };
  49.         [void]$s.add($text[$i]+"`t"+($t -join ','));
  50.     }else{
  51.         [void]$s.add($text[$i]+"`t无");
  52.     };
  53. };
  54. [IO.File]::WriteAllLines($outfile, $s, [Text.Encoding]::Default);
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 7# qixiaobin0715


    没赞助没动力
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 9# qixiaobin0715

那就扫码吧
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 7# qixiaobin0715


    已修改
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表