我想用curl在一个使用windows batch-file的网站上搜索一些模式。
如果搜索成功,如果curl能以某种方式返回一个积极的信号,那就太好了(例如,在成功的情况下返回1,在没有匹配的情况下返回0 )。
有谁知道如何做到这一点吗?
发布于 2020-04-16 03:01:06
使用cURL下载web内容,并将其输出重定向到findstr的输入,findstr在下载的内容中搜索模式出现。
curl.exe %url% | findstr "%pattern%" >NUL
if not errorlevel 1 (echo Pattern found!) else (echo Pattern not found)findstr限制管道输入长度为8k个字符。如果您数据某些行超过了这样的限制,请避免使用管道,将下载的数据保存到文件中:
curl.exe -o %filename% %url%
findstr "%pattern%" %filename% >NUL 2>&1
if not errorlevel 1 (echo Pattern found!) else (echo Pattern not found)https://stackoverflow.com/questions/61232245
复制相似问题