如何获取具有多个值的类属性的 Web 元素

时间:2021-01-26 04:35:19

标签: html xml selenium-webdriver web-scraping console

这是我的问题:我有这个 html enter image description here

如您所见,有两个 <div class="sc-fjhmcy dbJOiq flight-information"></div> 并且,我想使用 class 属性获取元素,但只能使用航班信息值,因为 我认为写成无意义代码的部分(“sc-fjhmcy dbJOiq ...)每天都在变化

我已经尝试过使用此 xmlpath $x('//div[contains(@class, "flight-information)"'],但它不起作用, 我能做什么?...

1 个答案:

答案 0 :(得分:0)

我检查了你的代码,我认为这没有什么大问题。 您需要使用一个类名来获取元素,而不是两个名称,如下所示。 $(".sc-fjhmcy") 然后,这将正确运行。 最好的问候