I want to remove the <br>
html tag while web scraping the page, but replace doesn't seem to work. i'm not sure if there is another way to do it or better way to do it using selenium and python. thank you in advance.
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
I tried this:
for i in courses_subheading:
courses_subheading.replace("<br>", " ")
but get an error: AttributeError: 'list' object has no attribute 'replace'
currently, it looks like this:
Course
Weight Title Notes Max
Credits OK
Through Disability
Course
but i want it like this:
Course Weight Title Notes Max Credits OK Through Disability Course
was close, you just need to use the iterator not the list – RichEdwards Aug 03 '20 at 12:15
", " ")` use: `i.replace("
", " ")` – Tasnuva Aug 03 '20 at 12:21