我想<br>在网络抓取页面时删除 html 标签,但替换似乎不起作用。我不确定是否有另一种方法或更好的方法使用 selenium 和 python 来做到这一点。先感谢您。
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome("drivers/chromedriver")
driver.get("https://web3.ncaa.org/hsportal/exec/hsAction")
state_drop = driver.find_element_by_id("state")
state = Select(state_drop)
state.select_by_visible_text("New Hampshire")
driver.find_element_by_id("city").send_keys("Moultonborough")
driver.find_element_by_id("name").send_keys("Moultonborough Academy")
driver.find_element_by_class_name("forms_input_button").send_keys(Keys.RETURN)
driver.find_element_by_id("hsSelectRadio_1").click()
courses_subheading = driver.find_elements_by_tag_name("th.header")
print(courses_subheading[0].text, " " ,courses_subheading[1].text, " ", courses_subheading[2].text, " ", courses_subheading[3].text, " ", courses_subheading[4].text
我试过这个:
for i in courses_subheading:
courses_subheading.replace("<br>", " ")
但得到一个错误:AttributeError: 'list' object has no attribute 'replace'
目前,它看起来像这样:
Course
Weight Title Notes Max
Credits OK
Through Disability
Course
但我想要这样:
Course Weight Title Notes Max Credits OK Through Disability Course
肥皂起泡泡
拉丁的传说
相关分类