【LINUX】shell中模拟爬虫

url_home="http://localhost:8080"

curl ${url_home} -o 1.html

cat 1.html | grep 'href="' | awk -F"\"" '{ print $2 }' >urls.txt

cat 1.html | grep 'href="' | awk -F"\"" '{ print 3 }' \| awk -F"\<" '{ print 1 }' | sed "s:>::g"|sed "s: :_:g" > titles.txt

打开文件1

exec 3< urls.txt

打开文件2

exec 4< titles.txt

读取文件1和文件2的内容

while read -u 3 url && read -u 4 title

do

echo "url: $url"

echo "title: $title"

curl "{url_home}/url" -o "${title}.html"

done

关闭文件

exec 3<&-

exec 4<&-

相关推荐
Avan_菜菜5 小时前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
Sokach101514 小时前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
SelectDB1 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao1 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3103 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode3 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
A小辣椒4 天前
TShark:Wireshark CLI 功能
linux
A小辣椒5 天前
TShark:基础知识
linux
AlfredZhao5 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci