以下是示例代码
<p>
I want this Text
<sup> not this </sup>
.(Need this too).
<sup> and not this </sup>
</p>
使用Selenium RC,selenium.getText("//...")带给我们所有的文本,包括< sup >中的文本。
有没有办法在没有<sup>标签的情况下从<p>中获取文本?
请让我知道。谢谢
忽略葡萄牙语的评论
from selenium import webdriver
from time import sleep
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
driver=webdriver.Chrome('C:/Users/LENOVO/Desktop/WEB SCRAPPING/Selenium/chromedriver.exe')#padrão
driver.get('https://stackoverflow.com/questions/726
我想从下面的html行中选择文本:
<h3 data-reacid ='64'> text to select <h3>
我尝试使用xpath。但是由于某些原因,selenium无法通过xpath找到该元素。我想通过'data-reactid‘属性选择文本。我不知道该怎么做。我在python中使用selenium。