要求输入一个url,输出该url是首页、目录页或者其他url
如下形式叫做首页:
militia.info/
如下形式叫做目录页:
thursdaythree.net/greenhouses--gas-global-green-house-warming/
请注意:
a) url有可能带http头也有可能不带
b)动态url(即含有"?"的url)的一律不算目录页,如:
下面是我实现的代码:
#!/bin/bash
#echo Please input the url:
#read urls
for url in $(cat urls)
do
echo $url | sed 's/^http:\/\///g' | grep '\/' | grep -v '\/.*\/' | grep -v '\?'
a1=$?
echo $url | sed 's/^http:\/\///g' | grep '\/.*\/' | grep -v '\?'
a2=$?
echo $url | grep '\?'
a3=$?
if [ $a1 -eq 0 ]
then
echo "$url is index page"
elif [ $a2 -eq 0 ]
then
echo "$url is directory page"
else
echo "$url is other page"
fi
done
阅读(1229) | 评论(0) | 转发(0) |