使用 XPath Google 工作表 importxml 函数从字典中获取单词的含义

Get meaning for a word from dictionary Using XPath Google sheets importxml function

我正在尝试使用 Google 工作表中的 IMPORTXML 函数来获取 https://www.powerthesaurus.org/

上的含义和信息词

我有点成功地从另一个网站获取了一些数据,但是作为一个新手,当我在 this Google sheet in D6 cell.

中尝试这个网站时,我在获取任何数据时遇到了一些麻烦
=ImportXML("https://www.powerthesaurus.org/"&A6,"//*[@id='link link--primary link--term']")

有人可以用正确的公式帮助我学习吗?

您正在查找同义词。请注意,您最多可以在 Power Thesaurus 上显示 200 个。 要在一个单元格中获取前 50 个同义词(因为每行有一个词),您可以试试这个:

在您的 Google 表格中创建 50 个带编号的列。 将此公式应用于第一个单元格并将其拖动到右侧。

=IMPORTXML("https://www.powerthesaurus.org/abbreviation/synonyms";"(//div[@class='pt-thesaurus-card__term'])"&"["&B2&"]")

然后使用连接公式获取一个单元格中的所有单词(XX:XX 是您的列的范围,B3:F3 在提供的屏幕截图中)。

=JOIN("|";XX:XX)

结果:

或者我们可以使用这个单行代码(然后进行一些清理)但是 GoogleSheet returns 一个空白单元格而 XPath 是完全有效的:

=IMPORTXML("https://www.powerthesaurus.org/abbreviation/synonyms";"normalize-space(//div[@class='pt-list-terms__container'])")