gpt4 book ai didi

html - 使用 ruby​​ 和 nokogiri 以 HTML 注释为标记解析 HTML

转载 作者:数据小太阳 更新时间:2023-10-29 08:25:39 25 4
gpt4 key购买 nike

我如何使用 ruby​​ 从包含这些行的表中提取信息?是否可以使用 nokogiri 检测评论?

<!-- Begin Topic Entry 4134 --> 
<tr>
<td align="center" class="row2"><image src='style_images/ip.boardpr/f_norm.gif' border='0' alt='New Posts' /></td>
<td align="center" width="3%" class="row1">&nbsp;</td>
<td class="row2">
<table class='ipbtable' cellspacing="0">
<tr>

<td valign="middle"><alink href='http://www.xxx.com/index.php?showtopic=4134&amp;view=getnewpost'><image src='style_images/ip.boardpr/newpost.gif' border='0' alt='Goto last unread' title='Goto last unread' hspace=2></a></td>

<td width="100%">
<div style='float:right'></div>
<div> <alink href="http://www.xxx.com/index.php?showtopic=4134&amp;hl=">EXTRACT LINK 1</a> </div>
</td>
</tr>
</table>
<span class="desc">EXTRACT DESCRIPTION</span>
</td>
<td class="row2" width="15%"><span class="forumdesc"><alink href="http://www.xxx.com/index.php?showforum=19" title="Living">EXTRACT LINK 2</a></span></td>
<td align="center" class="row1" width='10%'><alink href='http://www.xxx.com/index.php?showuser=1642'>Mr P</a></td>
<td align="center" class="row2"><alink href="javascript:who_posted(4134);">1</a></td>
<td align="center" class="row1">46</td>
<td class="row1"><span class="desc">Today, 12:04 AM<br /><alink href="http://www.xxx.com/index.php?showtopic=4134&amp;view=getlastpost">Last post by:</a> <b><alink href='http://www.xxx.com/index.php?showuser=1649'>underft</a></b></span></td>
</tr>
<!-- End Topic Entry 4134 -->
-->

最佳答案

尝试使用 xpath 代替:

html_doc = Nokogiri::HTML("<html><body><!-- Begin Topic Entry 4134 --></body></html>") 
html_doc.xpath('//comment()')

关于html - 使用 ruby​​ 和 nokogiri 以 HTML 注释为标记解析 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1175129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com