【Shell】模拟爬虫下载天龙八部小说

Shell脚本:

bash 复制代码
#curl https://tianlong.5000yan.com/ -o tianlong.html
grep "href=" tianlong.html | grep html | awk -F"\"" '{ print $6 }' >> urls.txt
grep "href=" tianlong.html | grep html | awk -F">" '{ print $3 }' | awk -F"<" '{ print $1 }' >>titles.txt

exec 3<urls.txt
exec 4<titles.txt

while read -u 3 url && read -u 4 title
do
	echo "$title : $url"
	curl "$url" -o "${title}.html"
done

exec 3<&-
exec 4<&-

下载后的文件:

下载后的效果:

相关推荐
Bdygsl9 分钟前
MySQL(6)—— 视图
数据库·mysql
oradh10 分钟前
数据库入门概述
数据库·oracle·数据库基础·数据库入门
BullSmall18 分钟前
一套定制化高级 payload 合集
数据库·安全性测试
x-cmd25 分钟前
[260326] x-cmd v0.8.10:跨 Shell 统一配置命令短名;自动装好依赖运行 WhisperLiveKit 实时语音转写
linux·人工智能·ai·whisper·shortcut·x-cmd
zhuyan10830 分钟前
【AI编程】aider安装记录
linux·运维·ai编程
zbdx不知名菜鸡32 分钟前
postgre sql 数据库查询优化
数据库·postgresql
9稳1 小时前
基于PLC的生产线自动升降机设计
开发语言·网络·数据库·嵌入式硬件·plc
书山有鹿1 小时前
MaxKB v2.7.0 Rocky Linux 9 部署手册
linux·运维·maxkb·rockylinux 9
Mapleay1 小时前
ALSA PCM 数据搬运模式
linux
四七伵1 小时前
Spring Boot项目中varchar字段为什么不用NULL?告别空指针从建表开始
数据库·后端