查找文本的正则表达式"这是标题"在这个标签内?使用Grep,Sed或Awk。
代码示例:
<h1 class="round title">
<a href="/somepage">This is the title</a>
</h1>
我已经在h1标签上试过了。
curl --silent http://domain.com/index.html | grep "<h1 class=\"round title\">"
结果是:
<h1 class="round title"><a href="/somepage">This is the title</a></h1>
我只需要&#34;这是标题&#34;部分内容。
答案 0 :(得分:1)
我用以下命令得到它。
curl --silent http://domain.com/index.html | grep -E "<h1.*><a.*>(.*?)</a></h1>" | sed 's/.*<a.*>\(.*\)<\/a>.*/\1/'
谢谢大家。