bash - 获取洋葱站点标题的 Bash 脚本
问题描述
我正在编写一个 bash 脚本,它给出了一个“.onion”站点列表和每个站点的 cURLs 页面标题,然后在新的文本文件中以以下格式输出:
“页面标题” - “xxxxxx.onion”
这是我到目前为止的代码,但我在如何实现我的目标方面遇到了困难。
# # echo '必须为 grep 安装 PCRE' 回声'' # # # 检查洋葱路由器连接 # RESP1="$(curl --socks5-hostname localhost:9150 -s 'https://check.torproject.org')" # # 回声 $RESP1 # 调试 RESP2=$(echo "$RESP1" | grep -m 1 "恭喜" | xargs) # 回声 $RESP2 # 调试 if [ "$RESP2"="恭喜。此浏览器配置为使用 Tor。" ] 然后 echo "连接到洋葱路由器" 别的 echo "连接洋葱路由器失败" 1号出口 菲 # 抓取网站的原始 html RESP3="$(xargs -n 1 curl --socks5-hostname localhost:9150 -so - < slist.txt)" # RESP3="$(curl --socks5-hostname localhost:9150 "$site" -so - )" #OLD # grep 标题 RESP4=$(echo "$RESP3" | grep -iPo '(?<=<title>)(.*)(?=</title>)') # 回声 $RESP4
解决方案
看来你快到了。
如果将脚本的最后一部分替换为:
cat slist.txt \
| while read -r url; do
# Grab raw html of site
RESP3="$(curl --socks5-hostname localhost:9150 -so - $url)"
# Grep for title
RESP4=$(echo "$RESP3" | grep -iPo '(?<=<title>)(.*)(?=</title>)')
#
echo "$RESP4 - $url"
done
只需将脚本的输出重定向到文本文件即可。这是你的目标还是我错过了什么?
推荐阅读
- reactjs - 如何在 reactJS 中使用 await 来获得完整的响应,而不仅仅是正文
- swift - UIPickerView 没有返回用户选择的正确行
- apache-spark - 将 Spark DataFrame 存储为 .csv 时重命名文件
- javascript - 将事件添加到 moment.js 日历中的特定日期?
- javascript - 如何将数据推送到javascript中的对象中?
- python-3.x - 2个系列/不同长度的列之间的模糊查找
- java - ThreadLocalRandom double 2 十进制
- url - 从 URL 访问 Samba 共享文件
- group-by - SELECT:按函数结果分组
- acumatica - 票据窗口未更新