我有个问题。我想使用 sed 或 grep 命令获取该 html 的两个部分的值。我怎样才能提取它们呢?
测试.html:
<html>
<body>
<div id="foo" class="foo">
Some Text.
<p id="author" class="author">
<br>
<a href="example.com">bar</a>
</p>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
脚本文件
#!/bin/bash
author=$(sed 's/.*<p id="author" class="author"><br><a href="*">\(.*\)<\/a><\/p>.*/\1/p' test.html)
quote=$(sed 's/.*<div id="foo" class="foo">\(.*\)<\/div>.*/\1/p' test.html)
Run Code Online (Sandbox Code Playgroud)
在该行下我只想要值中的文本。没有 html 标签。但我的脚本不起作用..