我正在努力刮这个网站的音乐会建议。我可以很容易地有UIPath刮名字( 1),地点(2)和日期(3)的音乐会(图1),但不是他们的分数(4)。
我可以从星星元素的名字中看到它们是"on“还是"off”。我想利用这些信息,让excel稍后算出分数。
然而,当我尝试刮取星号时,UIPath返回空列。我想这是因为它在这些项目中找不到任何文本,这是完全合理的。但是可以让UIPath返回列4、5、6等中的星号元素的名称吗?
链接到网站:http://soundvenue.com/musik/anmeldelser
(预先谢谢:)
发布于 2019-09-23 13:37:29
与RPA中的许多情况一样,有几种可能的解决方案。你可以循环每一个不可分割的项目,并检查“上”星星的数量,但如果你想使用摘录向导,它可能更容易修改之前提取网站上的数据,而不是之后。
我会尝试注射JavaScript,它会将文本附加到这些星星上,这将使RPA的提取变得更容易。
就像这样:
// Get an array of all star containers (span elements with "post-stars" class)
var ratings = $$("span.post-stars");
// Loop through them
for (i = 0; i < ratings.length; i++) {
// Get a number of all stars that are "on"
var starCount = ratings[i].getElementsByClassName("star-on").length;
// Create a new text node with the star value
var text = document.createTextNode(starCount);
// Append the text to the star container
ratings[i].appendChild(text);
}
然后,该网站将如下所示:
https://stackoverflow.com/questions/58058001
复制相似问题