网站制作学习网Linux→正文:linux shell 获取网页内容
字体:

linux shell 获取网页内容

Linux 2023/9/11 21:50:38  点击:不统计

www-fo-a-sp.cn

在判断网页服务是否可用,或者判断其是否被篡改,通过shell curl 获取页面内容。
代码如下(保存为.sh 即可运行):
#!/bin/bash
# 这里是 shell 获取网页内容
web_content=$(curl -s https://www.forasp.cn/)
# 输出网页内容
echo $web_content
# 判断含有某个字符串
aim_one="window.location.href"
aim_two="bad_word2:"
aim_three="bad_word3"
reload=false
if [[ $web_content =~ $aim_one ]] || [[ $web_content =~ $aim_two ]] || [[ $web_content =~ $aim_three ]]
then
  reload=true
fi
echo "`date +"%Y-%m-%d %H:%M:%S"`"
if [[ $reload == true ]]
then
echo "包含检查aim符号"
else
echo "不包含"
fi
 
以上就是shell 读取网页内容。

原文章%77w%77%2Ef%6F%72%61%73%70%2E%63n

·上一篇: Cannot find config.m4 >>    ·下一篇:The currently defined JAVA_HOME (@@HOMEBREW_JAVA@@) refers to a locati >>
推荐文章
最新文章