【发布时间】:2020-02-28 05:27:03
【问题描述】:
我正在获取带有 curl 的 html,并且只需要提取 第二个表格语句。 请注意,卷曲的 html 是单个字符串且未格式化。 为了更好地解释,请参见以下内容:(...代表更多 html)
...
<table width="100%" cellpadding="0" cellspacing="0" class="table">
...
</table>
...
#I need to extract the following table
#from here
<table width="100%" cellpadding="4">
...
</table> #to this
...
到目前为止,我尝试了多条 SED 行,而且我认为尝试像这样匹配第二个表并不是顺利的方式:
sed -n '/<table width="100%" cellpadding="4"/,/table>/p'
【问题讨论】:
-
你结婚了吗?改用 HTML/XML 解析器会更健壮。
-
不管做什么工作都会很棒
-
您要打印整个
语句还是只打印
语句中的内容?
@curusarn 完整声明我已经编写了一个打印表格语句的脚本。 (见下面我的回答)如果它不适合你,请务必发表评论。
标签: html regex sed html-parsing extraction