我一直试图从FAA的网站上搜索一张桌子 - > https://www.faa.gov/uas/legislative_programs/section_333/333_authorizations/ 使用Dataminer和Scaper chrome扩展。该表的源代码看起来像这样
<table id="auth_granted" class="striped">
<caption class="visuallyHidden">Authorizations Granted Via Section 333 Exemptions</caption>
<thead>
<tr>
<th scope="col">Grant Issued</th>
<th scope="col">Petitioner</th>
<th scope="col">Operation / Mission</th>
<th scope="col">Authorizations <small>(includes both petition and grant of exemption documents)</small></th>
</tr>
</thead>
<tbody>
<tr>
<td width="10%">9/25/2014</td>
<td width="25%">Astraeus Aerial</td>
<td width="35%">Closed-set filming</td>
<td width="30%"><a href="http://www.regulations.gov/#!docketDetail;D=FAA-2014-0352">View Documents</a></td>
</tr>
&#13;
我的问题是找到正确的xpath来显示表格行。我一直在尝试
//*[@id="auth_granted"]/tbody/tr[1]/td[2]
&#13;
但是我没有运气。有人有想法吗?建议将不胜感激!
答案 0 :(得分:1)
在xpath中指定确切的节点数时,只获得该节点。所以
//*[@id="auth_granted"]/tbody/tr[1]/td[2]
意味着你要去第一个tr并获得第二个td。你需要在没有括号的情况下这样做
//*[@id="auth_granted"]/tbody/tr/td
此外,您可以通过执行以下操作一直跳到td标记:
//*[@id="auth_granted"]/tbody//td
但是我会指定你在第一段中去一张桌子并避开*,这意味着所有节点。只要有可能,您应该定位特定节点。所以这可能是你最好的选择:
//table[@id="auth_granted"]/tbody//td
答案 1 :(得分:0)
Chrome控制台中的xpath语句正常工作。
所以我说&#34; Dataminer&#34; chrome扩展(它的网页抓取,而不是数据挖掘...)扩展只是缺陷。给出低分,报告错误(建议选择更合适的名称)并联系他们的支持。
或尝试使用程序员工具而不是网络浏览器扩展程序...如果您有代码问题,您确实有机会获得更好的答案而不是&#34;它应该有效,您使用的工具是打破&#34;,对不起。
答案 2 :(得分:0)
我需要的只是我的谷歌文档中的一个简单的IMPORTXML。这就是我试图做的事情。
= IMPORTXML(“https://www.faa.gov/uas/legislative_programs/section_333/333_authorizations/”,“// tr”)
谢谢!