I have an array of strings that I am scraping that looks like this ["https://rotogrinders.com/players/charlie-culberson-13456?format=json",
"https://rotogrinders.com/players/charlie-culberson-13456?format=json"]
I want to remove the https://rotogrinders.com/players/ part from each string in the array. How would I do this?
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
browser = webdriver.Chrome("/ProgramData/chocolatey/bin/chromedriver.exe")
browser.get("https://rotogrinders.com/projected-stats/mlb-hitter?site=fanduel")
# Wait 20 seconds for page to load
timeout = 20
try:
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((By.CLASS_NAME, 'player-popup')))
except TimeoutException:
print("Timed out waiting for page to load")
browser.quit()
# find_elements_by_xpath returns an array of selenium objects.
players_info = []
players = browser.find_elements_by_css_selector('div.player')
for player in players:
link = player.find_element_by_class_name('player-popup')
players_info.append(link.get_attribute('href'))