使用curl在批处理中访问网站

背景:
系统有一个功能, 需要通过批处理定时调用, 该功能在Web站点,且需要登陆。

实现:
使用Windows计划任务, 每天晚上执行批处理, 批处理文件中使用 curl进行登陆并执行相应命令

指定SessoinId并登陆系统
curl --cookie "ASP.NET_SessionId=bt133wlua5f5vuv51oigkut1" -d "username=xxx&password=xxx" https://website/login/index

执行命令
curl --cookie "ASP.NET_SessionId=bt133wlua5f5vuv51oigkut1" https://website/function1/do

附:curl 下载站点:https://curl.haxx.se/windows/

posted @ 2019-11-29 11:20  iyxqj  阅读(1010)  评论(0编辑  收藏  举报