html - 从 .html 文件中获取 IP
问题描述
他们是一个带有 socks4 在线代理的网站,我在代理链程序中使用它。我没有手动输入新的 IP,而是试图自动化这个过程。我使用 wget 将其转换为我的主目录中的 .html 文件,这是我 cat 文件时的一些输出:
</font></a></td><td colspan=1><font class=spy1>111.230.138.177</font> <font class=spy14>(Shenzhen Tencent Computer Systems Company Limited)</font></td><td colspan=1><font class=spy1>6.531</font></td><td colspan=1><TABLE width='13' height='8' CELLPADDING=0 CELLSPACING=0><TR BGCOLOR=blue><TD width=1></TD></TR></TABLE></td><td colspan=1><font class=spy1><acronym title='311 of 436 - last check status=OK'>71% <font class=spy1>(311)</font> <font class=spy5>-</font></acronym></font></td><td colspan=1><font class=spy1><font class=spy14>05-jun-2020</font> 23:06 <font class=spy5>(4 mins ago)</font></font></td></tr><tr class=spy1x onmouseover="this.style.background='#002424'" onmouseout="this.style.background='#19373A'"><td colspan=1><font class=spy14>139.99.104.233<script type="text/javascript">document.write("<font class=spy2>:<\/font>"+(a1j0e5^q7p6)+(m3f6f6^r8c3)+(a1j0e5^q7p6)+(t0b2s9^y5m3)+(w3c3m3^z6j0))</script></font></td><td colspan=1>SOCKS5</td><td colspan=1><a href='/en/anonymous-proxy-list/'><font class=spy1>HIA</font></a></td><td colspan=1><a href='/free-proxy-list/CA/'><font class=spy14>Canada</
如您所见,IP 通常后跟一个 spy[0-19]> 。我尝试使用以下代码使用 awk 解析出实际 IP:
awk '/^spy/{FS=">"; print $2 } file-name.html
这是有问题的,因为它们会在 IP 之后出现一堆其他的东西,而且我猜锚点在一行的开头起作用?无论如何,我想知道是否有人可以给我任何关于如何使用 awk 解析 IP 地址的想法。我刚开始学习awk,很抱歉这个菜鸟问题。谢谢
解决方案
这里已经提供了解决方案,我宁愿为使用egrep实用程序的未来读者提供不同的解决方案。
egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' file.html
推荐阅读
- c++ - How to correctly create std::string from a std::string_view?
- json - How to insert new table with JSON data through API in Azure SQL Database
- ruby-on-rails - Rails 启动服务器在找不到图像时出现错误。如何修复此错误?
- reactjs - ReactNative - 强制在 react-native-tab-view 中重新渲染子组件
- swift - 如何从以流明表示的“ambientIntensity”中获取 Lux 值?
- c - 等待字符串中的字符
- jsf - 在rich:fileUpload 中,如果用户超过了最大上传限制,那么我们如何显示一个弹出消息来说明这一点
- python - 如何连接使用内存映射 IO 填充的两个 TIFF 文件
- python - 更改一个特定的表单字段时,HTML 表单行消失
- postgresql - 如何将数据库模式从数据库 A 复制到数据库 B