google-sheets-formula - =IMPORTXML 不导入预期的内容
问题描述
我正在尝试将部门和行业标签导入谷歌文档。
我在用...
=IMPORTXML("https://finance.yahoo.com/quote/ABT/profile?p=ABT","//span[@data-reactid='21']")
在三个不同的单元格中显示:
Profile
Healthcare
About Our Ads
但我想要的只是一个细胞中的医疗保健
=IMPORTXML("https://finance.yahoo.com/quote/ABT/profile?p=ABT","//span[@data-reactid='25']")
在三个不同的单元格中显示:
Financials
Medical Devices
Sitemap
但我想要的只是一个单元中的医疗设备
我的语法有什么问题?
解决方案
我认为您也得到了另外两个span
s - 因此是三行而不是一排。
您可能想要使用更精确的 xpath,例如:
=IMPORTXML(
"https://finance.yahoo.com/quote/ABT/profile?p=ABT",
"//p/span[text()='Sector']/following-sibling::span[1]/text()")
=IMPORTXML(
"https://finance.yahoo.com/quote/ABT/profile?p=ABT",
"//p/span[text()='Industry']/following-sibling::span[1]/text()")
推荐阅读
- javascript - 对象方法中的局部变量音频未播放
- java - 带有 where 子句的计数的 jpa 条件子查询
- java - 为 json 字符串创建 JSON 对象 Pojo
- drupal - 制作页面的 Drupal 问题
- bash - 找到文件并设置自动任务以稍后使用命令检查它
- javascript - Ionic 3:$dirty 按钮显示
- webrtc - TURN 服务器中有多少个 WebRTC 连接?
- amazon-web-services - AWS CodeBuild CODEBUILD_SOURCE_VERSION 不正确
- php - 阻止文件下载 301 Moved Permanently 用于 HSTS 的 url
- php - 在 Laravel 5.7 中使用 Phpredis