我试图在LibreOffice Calc中编写一个宏,它将从一个单元格(例如Stark)中读取一个贵族House of Westeros的名字,然后通过查看the relevant page在冰与火的Wiki上输出该House的单词 . 它应该像这样工作:
这是伪代码:
Read HouseName from column A
Open HtmlFile at "http://www.awoiaf.westeros.org/index.php/House_" & HouseName
Iterate through HtmlFile to find line which begins "<table class="infobox infobox-body"" // Finds the info box for the page.
Read Each Row in the table until Row begins Words
Read the contents of the next <td> tag, and return this as a string.
我的问题是第二行,我不知道如何读取HTML文件 . 我应该如何在LibreOffice Basic中执行此操作?
1 回答
这有两个主要问题 . 1.性能您的UDF需要在存储它的每个单元中获取HTTP资源 . 2. HTML遗憾的是,OpenOffice或LibreOffice中没有HTML解析器 . 只有一个XML解析器 . 这就是我们无法直接使用UDF解析HTML的原因 .
这将有效,但速度慢且不太普遍:
更好的方法是,如果您可以从Wiki提供的Web API获取所需的信息 . 你知道Wiki背后的人吗?如果是这样,那么你可以把它放在那里作为建议 .
问候
阿克塞尔