首页 > 解决方案 > 如何检索 xpath 的内部文本?

问题描述

我想要来自 xpath 的内部文本

我正在尝试这个,但到目前为止我无法得到文本

  const download = await frame.$x(xpath);
  const downloadText = await download[0].getProperty('textContent');
  console.log(downloadText);

结果是,以下



JSHandle {
...
    _targetType: 'page',
    _sessionId: '14CCB014112B47319CA8A1C810F23B18'
  },
  _remoteObject: { type: 'string', value: '20200129_1500.zip' },
  _disposed: false
}

我想检索 _remoteObject 中的值,我已经尝试了几乎所有我找到的东西,但似乎没有什么对我有用。

请帮帮我。

标签: javascriptnode.jsxpathpuppeteer

解决方案


这工作得很好!

  const text = await (await download[0].getProperty('textContent')).jsonValue();


推荐阅读