0
我想要制作一个自动化应用程序,只想从另一个页面中选择一些表中的条目并在表中写入这些条目。问题是我的源HTML(我从中获取数据)没有id
属性设置,因此我真的很难获得只有的一些字段。我的HTML看起来像:从另一个网页只获取表格的一些条目
<section id="file">
<div class="section-title">
<h4>File Details</h4>
</div>
<table class="table table-striped table-bordered">
<colgroup>
<col width="150" />
<col width="*" />
</colgroup>
<tr>
<th>File name</th>
<td><span class="mono">1636d19724ac08f3c48235e27c2bc26d</span></td>
</tr>
<tr>
<th>File size</th>
<td><span class="mono">67584 bytes</span></td>
</tr>
<tr>
<th>File type</th>
<td><span class="mono">PE32 executable (GUI) Intel 80386, for MS Windows</span></td>
</tr>
<tr>
<th>CRC32</th>
<td><span class="mono">96AE0B79</span></td>
</tr>
</table>
</section>
我的jQuery脚本目前的样子:
$("#first").load("report.html #file table:nth-child(2)");
(我已经给定的目标HTML文件不同的标签ID为的像first
,所以我打算写很多这样的) 。此行尝试只提取一个值,即File Name
表格行。 但我得到整个表。
我在哪里错了? 任何帮助。 谢谢。
@BenM它没有。结帐:http://api.jquery.com/load/向下滚动到'加载页面片段'部分。 –
你确定'report.html'的路径吗? –
'table:nth-child(2)'之前有一个额外的空间。 –