找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 21568|回复: 0

[原创代码] 抓取btrenren电影网站上的torrent下载链接需要给invoke-restmethod传递post参数的构造

[复制链接]
发表于 2018-3-17 21:49:02 | 显示全部楼层 |阅读模式
本帖最后由 gflrlm 于 2018-3-17 22:09 编辑

比如访问 [url= http://www.btrenren.com/index.ph ... l?id=17072&zz=1]
模拟点击“点击下载”按钮 ,需要进行如下操作:

####################################################################################
### 下面是上面网页的源代码 ,关键内容如下,需要构$body 数据给 -post 参数
### 实际上,不需要再访问上面的网址, 只需要根据 id 和zz 构造出body即可下载了。
### view-source: http://www.btrenren.com/index.ph ... l?id=17072&zz=1
###      # <form action="" method="post">
###      # <input type="hidden" value="17072" name="id">
###      # <input type="hidden" value="zz1" name="zz">
###      # <input name="imageField" type="image" width="140" height="55" src="http://www.btrenren.com/Public/Home/images/download.gif" style="cursor:pointer;">
###      # </form>

###
####################################################################################

  1. $body = @{
  2.      "zz"="zz1"          ### <input type="hidden" value="download"
  3.      "id"="17072"        ### <input type="hidden" value="17072" #output torrent file
  4.      "id"="23681"        ### <input type="hidden" value="23681" #redirect to a new web html

  5. }
  6. $torrent_filename="xxxxx.torrent"
  7. 注意下面的uri 网址 http://www.btrenren.com/index.php/Dow/index.html ,取自源代码里面皿form action = ""
  8.   invoke-restmethod -uri http://www.btrenren.com/index.php/Dow/index.html -Body $body -Method Post -OutFile $torrent_filename
复制代码
有时候对torrent文件进行命名的时候,我们需要根据抓到的网页里面的title进行命名,比如 $torrent_filename= "[BT下载][狼吻夜惊魂][HD-MP4/1.8GB][中文字幕][1080P]"       

<span><a href="http://www.btbtt88.com/thread-index-fid-1-tid-14215.htm"><title ="[BT下载][狼吻夜惊魂][HD-MP4/1.8GB][中文字幕][1080P]"</a></span>


此时会提示错误: -outfile 通配符 路径不存在 。 这个时候需要将里面的特殊字符 [ ] : ? 等替换掉 , 使用下面的函数:

  1.   function escape_wildcards_to____string([string] $s) {
  2.    $s1 = $s -replace '\[','___'
  3.    $result = $s1 -replace '\]','___'
  4.    $result = $result -replace '\*','___'
  5.    $result = $result -replace '\?','___'
  6.    $result = $result -replace '\/','___'
  7.    $result = $result -replace '\\','___'
  8.    $result = $result -replace '\:','___'
  9.    return $result
  10. }

复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 01:33 , Processed in 0.016848 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表