You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用IMPORTXML查找含playerlocation的方格并提取坐标?

定位含playerlocation的方格及坐标提取方案

1. 精准匹配目标方格的XPath表达式

要找到包含playerlocation类的方格,直接用XPath的contains()函数即可,结合你提供的地图根路径,最终表达式为:

/html/body/div/div/div[3]/div/div[2]/div/div/table/tbody//td[contains(@class, 'playerlocation')]

2. 表达式解析

  • //td:从地图的tbody节点开始,递归查找所有层级的td方格元素,无需逐个指定行和列位置
  • contains(@class, 'playerlocation'):匹配class属性中包含playerlocation字符串的td元素,兼容class里同时存在坐标、区域名称等其他值的情况

3. 坐标提取方法

拿到匹配的td元素后,从其class属性中提取坐标:

  • 先获取完整的class属性值,例如:coord x1054 y987 secronomBunker playerlocation
  • 使用正则表达式x(\d+)和y(\d+)分别提取x、y的数字部分,最终组合成x#### y####格式的坐标字符串

内容的提问来源于stack exchange,提问作者Dat Guy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 18:40:28