批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

实验楼挂机批处理脚本

http://my.oschina.net/ysj/blog/517756

玩来玩去还是那一套,fiddler抓包,导出curl script,存为xx.bat,改一改批处理加个goto,一个循环发HTTP请求挂机的脚本就出来了,感觉很方便啊。

正常情况使用实验楼学习,并保持有输入,学习时间就可以累加。这次就做了这么一个挂机脚本。

fiddler抓包发现,每隔一段时间,浏览器会自动产生两个POST:

POST https://www.shiyanlou.com/courses/result/studytime/add HTTP/1.1

POST https://www.shiyanlou.com/courses/running/input HTTP/1.1

-隐约明白了这两个会话的意思是要告诉服务器要增加学习时间。那么我们只需要每隔60秒重放一次这两个请求就可以实现挂机了。分别导出XXX.BAT,得到两条很长的curl命令,合并到一个文件中:
curl -k -i --raw -o 0.dat -X POST "https://www.shiyanlou.com/courses/result/studytime/add" -H "Host: www.shiyanlou.com" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: https://www.shiyanlou.com" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" -H "DNT: 1" -H "Referer: https://www.shiyanlou.com/courses/running/291" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: zh-CN,zh;q=0.8,en;q=0.6" -H "Cookie: remember_token=171302|gggg130497a982ce1f6c15484f53b0797c60f02e; session=101f60e0-f007-4478-aa5c-1ae820d09cd5.ZM8ZAwaHXV6kz5FranTu9JHpmsQ"

curl -k -i --raw -o 0.dat -X POST -d "lab_id=291&data=70%%2C83%%2C70%%2C68%%2C83%%2C83%%2C70%%2C83%%2C68%%2C70%%2C13%%2C83%%2C68%%2C70%%2C83%%2C68%%2C70%%2C13%%2C68%%2C68%%2C70%%2C71%%2C16%%2C13%%2C83%%2C76%%2C69%%2C69%%2C80%%2C32%%2C13%%2C87%%2C72%%2C73%%2C8%%2C8%%2C8%%2C87%%2C72%%2C73%%2C69%%2C8%%2C76%%2C69%%2C32%%2C13%%2C83%%2C69%%2C76%%2C8%%2C8%%2C76%%2C69%%2C69%%2C80%%2C32%%2C49%%2C13%%2C186%%2C13%%2C186%%2C13%%2C17%%2C67" "https://www.shiyanlou.com/courses/running/input" -H "Host: www.shiyanlou.com" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: https://www.shiyanlou.com" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "DNT: 1" -H "Referer: https://www.shiyanlou.com/courses/running/291" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: zh-CN,zh;q=0.8,en;q=0.6" -H "Cookie: remember_token=171302|gggg130497a982ce1f6c15484f53b0797c60f02e; session=101f60e0-f007-4478-aa5c-1ae820d09cd5.ZM8ZAwaHXV6kz5FranTu9JHpmsQ"
Batch-CN 是一个windows 下的命令行工具包管理器,安装后使用以下这两命令分别安装curl.exe和sleep.exe:

gt curl
gt sleep
加上goto 循环调用和sleep 就可以得到每60秒自动重放HTTP请求的挂机脚本了。
  1. @echo off
  2. :g
  3. curl -k -i --raw -o 0.dat -X POST "https://www.shiyanlou.com/courses/result/studytime/add" -H "Host: www.shiyanlou.com" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: https://www.shiyanlou.com" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" -H "DNT: 1" -H "Referer: https://www.shiyanlou.com/courses/running/291" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: zh-CN,zh;q=0.8,en;q=0.6" -H "Cookie: remember_token=171302|ggggg30497a982ce1f6c15484f53b0797c60f02e; session=101f60e0-f007-4478-aa5c-1ae820d09cd5.ZM8ZAwaHXV6kz5FranTu9JHpmsQ"
  4. curl -k -i --raw -o 0.dat -X POST -d "lab_id=291&data=70%%2C83%%2C70%%2C68%%2C83%%2C83%%2C70%%2C83%%2C68%%2C70%%2C13%%2C83%%2C68%%2C70%%2C83%%2C68%%2C70%%2C13%%2C68%%2C68%%2C70%%2C71%%2C16%%2C13%%2C83%%2C76%%2C69%%2C69%%2C80%%2C32%%2C13%%2C87%%2C72%%2C73%%2C8%%2C8%%2C8%%2C87%%2C72%%2C73%%2C69%%2C8%%2C76%%2C69%%2C32%%2C13%%2C83%%2C69%%2C76%%2C8%%2C8%%2C76%%2C69%%2C69%%2C80%%2C32%%2C49%%2C13%%2C186%%2C13%%2C186%%2C13%%2C17%%2C67" "https://www.shiyanlou.com/courses/running/input" -H "Host: www.shiyanlou.com" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: https://www.shiyanlou.com" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "DNT: 1" -H "Referer: https://www.shiyanlou.com/courses/running/291" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: zh-CN,zh;q=0.8,en;q=0.6" -H "Cookie: remember_token=171302|ggggg130497a982ce1f6c15484f53b0797c60f02e; session=101f60e0-f007-4478-aa5c-1ae820d09cd5.ZM8ZAwaHXV6kz5FranTu9JHpmsQ"
  5. sleep 60
  6. goto g
复制代码

?咦?标题怎么成批处理脚本了?

TOP

返回列表