[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 zaqmlp 于 2021-10-10 20:53 编辑
  1. <# :
  2. rem www.tvzn.com
  3. rem 另存为ANSI编码的bat
  4. cls&echo off&cd /d "%~dp0"
  5. powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
  6. pause
  7. exit
  8. #>
  9. $infile='.\文本c.txt';
  10. $outfile='.\结果.txt';
  11. if(-not (test-path -liter $infile)){write-host ('"'+$infile+'" 未找到');exit;};
  12. $enc=[System.Text.Encoding]::UTF8;
  13. $webclient=New-Object System.Net.WebClient;
  14. function gethtml($u){
  15.     $t='';
  16.     for($j=1;$j -le 3;$j++){
  17.         try{
  18.             $webclient.Headers.Add('User-Agent','Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36');
  19.             $webclient.Encoding=$enc;
  20.             $t=$webclient.DownloadString($u);
  21.             break;
  22.         }catch{
  23.             write-host ('第'+$j.toString()+'次获取网页源码失败');
  24.             start-sleep -Seconds 3;
  25.         };
  26.     };
  27.     return $t;
  28. };
  29. $fs=New-Object System.IO.FileStream($outfile, [System.IO.FileMode]::Create);
  30. $sw=New-Object System.IO.StreamWriter($fs, $enc);
  31. $text=[IO.File]::ReadAllText($infile, $enc).split("`r`n",[StringSplitOptions]::RemoveEmptyEntries);
  32. for($i=0;$i -lt $text.Count;$i++){
  33. write-host ('--------------'+$text[$i]+'--------------');
  34. $url=$text[$i].trimend(' /')
  35. $url1=$url+'/juqingjieshao.html';
  36. $html1=gethtml $url1;
  37. $title='TTT';
  38. $m1=[regex]::match($html1,'>([^<]+?)</h1></div>');
  39. if($m1.Success){$title=$title+$m1.groups[1].value.replace('剧情介绍','');}
  40. write-host $title;
  41. $sw.WriteLine($title);
  42. $m1=[regex]::match($html1,'<div id="danji"[^>]*?>([\s\S]+?)</div></div></div>');
  43. if($m1.Success){
  44. $m2=[regex]::matches($m1.groups[1].value, '<a class="link" href="([^"]+?)">(\d+)</a>');
  45. for($j=$m2.Count-1;$j -ge 0;$j--){
  46. $sw.WriteLine('第'+$m2[$j].groups[2].value+'集');
  47. $url2=($url -replace '^(https?://[^/]+).+','$1')+$m2[$j].groups[1].value;
  48. write-host ($m2[$j].groups[2].value+' '+$url2);
  49. $html2=gethtml $url2;
  50. $m3=[regex]::match($html2,'<div>.*?<center>.*?</center>.*?<br>([\s\S]+?)<div');
  51. if($m3.Success){
  52. $contant=(($m3.groups[1].value -replace '<p>','') -replace '&nbsp;',' ') -replace '</p>',"`r`n";
  53. $contant=$contant.trim();
  54. $sw.WriteLine($contant);
  55. $sw.Flush();
  56. }
  57. }
  58. }
  59. $sw.WriteLine('');
  60. }
  61. $sw.Close();
  62. $fs.Close();
复制代码
1

评分人数

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

TOP

本帖最后由 zaqmlp 于 2021-10-11 16:21 编辑
  1. <# :
  2. rem www.tvmao.com
  3. rem 另存为ANSI编码的bat
  4. cls&echo off&cd /d "%~dp0"
  5. powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
  6. pause
  7. exit
  8. #>
  9. $starturl=1;
  10. $minilen=160;
  11. $timeout=900;
  12. $infile='.\文本b.txt';
  13. $outfile='.\结果.txt';
  14. if(-not (test-path -liter $infile)){write-host ('"'+$infile+'" 未找到');exit;};
  15. $enc=[System.Text.Encoding]::UTF8;
  16. $webclient=New-Object System.Net.WebClient;
  17. function gethtml($u){
  18.     $t='';
  19.     for($j=1;$j -le 3;$j++){
  20.         try{
  21.             $webclient.Headers.Add('User-Agent','Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36');
  22.             $webclient.Encoding=$enc;
  23.             $t=$webclient.DownloadString($u);
  24.             break;
  25.         }catch{
  26.             write-host ('第'+$j.toString()+'次获取网页源码失败');
  27.             start-sleep -Seconds 3;
  28.         };
  29.     };
  30.     return $t;
  31. };
  32. function getcontent($u){
  33. $content='';
  34.     $html2=gethtml $u;
  35.     $m3=[regex]::match($html2,'<article class="clear epi_c"[^>]*?>([\s\S]+?)</article>');
  36.     if($m3.Success){
  37.         $content=((($m3.groups[1].value -replace '<p>','') -replace '&nbsp;',' ') -replace '</p>',"`r`n") -replace '<div(?: [^>]*?)?>[\s\S]+?</div>','';
  38.         $content=(($content -replace '<[^>]+?>','') -replace '</?[a-z]+','').trim();
  39.     }
  40.     return $content;
  41. }
  42. $fs=New-Object System.IO.FileStream($outfile, [System.IO.FileMode]::Append);
  43. $sw=New-Object System.IO.StreamWriter($fs, $enc);
  44. $text=[IO.File]::ReadAllText($infile, $enc).split("`r`n",[StringSplitOptions]::RemoveEmptyEntries);
  45. for($i=0;$i -lt $text.Count;$i++){
  46. if(($i+1) -ge $starturl){
  47. write-host ('--------------'+$text[$i]+'--------------');
  48. $result=New-Object -TypeName System.Collections.ArrayList;
  49. $url=$text[$i].trimend(' /')
  50. $url1=$url+'/episode';
  51. $html1=gethtml $url1;
  52. $title='TTT';
  53. $m1=[regex]::match($html1,'title="([^"]+?)剧情介绍".*?>介绍');
  54. if($m1.Success){$title=$title+$m1.groups[1].value.replace('剧情介绍','');}
  55. write-host $title;
  56. [void]$result.add($title);
  57. $m1=[regex]::match($html1,'<div class="epipage clear">([\s\S]+?)</div>');
  58. if($m1.Success){
  59. $m2=[regex]::matches($m1.groups[1].value, '<li(?: [^>]*?)?>.*?href="([^"]+?)"[^>]*?>(\d+)</a></li>');
  60. for($j=0;$j -lt $m2.Count;$j++){
  61. [void]$result.add('第'+$m2[$j].groups[2].value+'集');
  62. $url2=($url -replace '^(https?://[^/]+).+','$1')+$m2[$j].groups[1].value;
  63. write-host ($m2[$j].groups[2].value+' '+$url2);
  64. $t=0;
  65. while(1){
  66. $ct=getcontent $url2;
  67. write-host $ct.length;
  68. if($ct.length -gt $minilen){
  69. [void]$result.add($ct);
  70. break;
  71. }else{
  72. $t++;
  73. }
  74. if($t -ge 3){
  75. $t=0;
  76. write-host ('字符数少于'+$minilen+',暂停'+$timeout+'秒……');
  77. start-sleep -Seconds $timeout;
  78. }
  79. }
  80. }
  81. }
  82. $s=$result -join "`r`n";
  83. $sw.WriteLine($s);
  84. $sw.WriteLine('');
  85. $sw.Flush();
  86.     }
  87. }
  88. $sw.Close();
  89. $fs.Close();
复制代码
1

评分人数

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

TOP

回复 5# lxh623

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

TOP

返回列表