【发布时间】:2019-11-20 17:23:35
【问题描述】:
我想提取红色和绿色矩形中包含的文本,如下面的屏幕截图所示, 注意:文本不包含在开始和结束标记中
http://temperate.theferns.info/plant/Acacia+omalophylla
例如,对于绿色矩形的文本,我测试了这个 xpath 查询和以下代码(python/selenium):
greenrec_xpath = "//*[preceding::h3[contains(text(), 'General Information')] and following::h3[contains(text(), 'Known Hazards')]]"
driver.find_elements_by_xpath(greenrec_xpath)
但没有得到预期的结果
任何想法!
【问题讨论】:
-
你可以通过 By.Xpath("//div[@class='family']/following-sibling::br[1]") 然后 .Text() .第二批比较棘手,因为没有标签。
-
Bertrand,你试过我的解决方案了吗?解决问题了吗?
-
谢谢! Dimitre Novatchev,明天我将发布解决方案!
标签: javascript python selenium xpath webdriverwait