如何使用Selenium从网站上删除文本

时间:2018-02-11 21:42:00

标签: python selenium pyautogui

如何使用Selenium从网站上删除文字? 我需要从网站上获取内部文本。我正在使用最新的Python和Selenium,这些都是最新的。我也有pyautogui。

这是我需要抓的东西:

<span  class="ng-binding" ng-bind-html="addKeysInMatch(characterMatch.bad)">Gorgeous Geodes Glowed</span>

我不知道文本的一部分,“华丽的Geodes Glowed”是我不知道的,我需要找到它。

提前致谢。

1 个答案:

答案 0 :(得分:1)

titles_element = driver.find_elements_by_xpath("//span[@class='ng-binding']")
titles = [x.text for x in titles_element]
titles = []
for x in titles_element:
    titles.append(x.text)
print(titles)

Gorgeous Geodes Glowed是在span类被识别后出现的文本。因此,每次出现此类时,它将打印出以下文本。