Chinaunix

标题: [已用它法解决]shell获取td标签中的文本内容 [打印本页]

作者: flyinweb_cu    时间: 2013-01-15 09:10
标题: [已用它法解决]shell获取td标签中的文本内容
本帖最后由 flyinweb_cu 于 2013-01-15 12:46 编辑

<td class="classname"><a href="http://a1.com" target="_blank">a1.com</a></td>

<td class="classname"><a href="http://a2.com" target="_blank">a2.com</a></td>

<td class="classname"><a href="http://a3.com" target="_blank">a3.com</a></td>

页面出现以表格方式列出很多的域名列表,shell是否可以打印出如下格式:


a1.com
a2.com
a3.com
作者: murdercool    时间: 2013-01-15 09:19
grep -oP "(?<=http://)[^\"]*" testfile
作者: udevu    时间: 2013-01-15 09:28
  1. awk -F"<|>" '{print $5}'
复制代码
  1. sed 's/<[^>]*>//g'
复制代码

作者: seesea2517    时间: 2013-01-15 11:29
都要求用 shell 做 xml html 的东西,建议版主弄一个模块,以后见帖粘贴~
作者: flyinweb_cu    时间: 2013-01-15 12:46
本帖最后由 flyinweb_cu 于 2013-01-15 15:16 编辑

页面内容比较复杂,代码没有贴全,上述回复实现起来还有些问题,用C#写了个命令行工具处理了
作者: Shell_HAT    时间: 2013-01-15 13:51
回复 5# flyinweb_cu


    不是上述代码无法实现,而是你在顶楼给的数据不充分。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2