for b in driver.find_elements_by_xpath("//a/following-sibling::b"):
print(b.text)
聊天后提供的解决方案:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("http://www.drugs.com/drug-class/laxatives.html?condition_id=&generic=0&sort=rating&order=desc")
# wait for the table list to load
table = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "table.data-list")))
for b in table.find_elements_by_css_selector("tr td > a[href] > b"):
print(b.text)
假设您试图依赖前面的} ,例如:
a
元素,请使用^{Python代码:
^{pr2}$如果希望多个
b
标记具有a
作为前一个元素:聊天后提供的解决方案:
相关问题 更多 >
编程相关推荐