从这个link我想获得排名位置标志,我使用这个获得图像链接:
=IMPORTXML("https://int.soccerway.com/national/england/premier-league/20172018/regular-season/r41547/tables/","//table[@class='leaguetable sortable table detailed-table']//tr/td[@class='direction']/img/@src")
是的,我得到了img url。
https://s1.swimg.net/gsmf/678/img/delta_plus.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
https://s1.swimg.net/gsmf/678/img/delta_plus.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
https://s1.swimg.net/gsmf/678/img/delta_plus.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
但如何获得内部没有元素的<td class="direction"></td>
?
某些元素有这样的img标签:
<td class="direction"><img src="https://s1.swimg.net/gsmf/678/img/delta_plus.gif" width="7" height="4" title="Previous rank: 4" alt="Previous rank: 4"></td>
另一个元素里面没有img标签:
<td class="direction"></td>
如何获取内部没有数据的元素,这样我就可以得到这样的列表:
https://s1.swimg.net/gsmf/678/img/delta_plus.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
https://s1.swimg.net/gsmf/678/img/delta_plus.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
https://s1.swimg.net/gsmf/678/img/delta_plus.gif
https://s1.swimg.net/gsmf/678/img/delta_min.gif
我该怎么办?感谢
答案 0 :(得分:1)
您想同时检索<td class="direction"></td>
和<td class="direction"><img ... /></td>
。当td
没有<img ... />
时,您想要放置空行。如果我的理解是正确的,那么这个修改怎么样? https://int.soccerway.com/national/england/premier-league/20172018/regular-season/r41547/tables/
放入&#34; A1&#34;。
=IMPORTXML(A1,"//td[@class='direction' and not(*)] | //td[@class='direction']/img/@src")
//td[@class='direction' and not(*)]
表示td
为class
且direction
且没有子元素。//td[@class='direction']/img/@src
表示td
具有img
的子元素,并检索@src
。通过这些,当td
的{{1}}具有@class='direction'
的子元素时,会检索img
。 <{1}}的{{1}}没有子元素时,将放空。
@src
。如果我误解了你的问题,我很抱歉。