o se pudo obtener fechas de forma tabulada de un contenido tabula
He escrito un script en Python en combinación con selenio para analizar algunas fechas disponibles dentro de una tabla en una página web. La tabla se encuentra debajo del encabezadoNPL Victoria Betting Odds
. Los datos tabulares están dentro del idtournamentTable
. Puedes ver las tres fechas allí10 Aug 2018
,11 Aug 2018
y12 Aug 2018
. Deseo analizarlos y organizarlos de acuerdo con mi salida esperada a continuación.
Este es mi intento hasta ahora:
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
from bs4 import BeautifulSoup
link = "find the link above"
def get_content(driver,url):
driver.get(url)
for items in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,"#tournamentTable tr"))):
try:
idate = items.find_element_by_css_selector("th span[class^='datet']").text
except Exception: idate = ""
try:
itime = items.find_element_by_css_selector("td.table-time").text
except Exception: itime = ""
print(f'{idate}--{itime}')
if __name__ == '__main__':
driver = webdriver.Chrome()
wait = WebDriverWait(driver,10)
try:
get_content(driver,link)
finally:
driver.quit()
Actualmente tengo resultados como:
--
10 Aug 2018--
--
--09:30
--10:15
11 Aug 2018--
--
--05:00
--05:00
--09:00
12 Aug 2018--
--
--06:00
--06:00
Mi salida esperada:
10 Aug 2018--09:30
10 Aug 2018--10:15
11 Aug 2018--05:00
11 Aug 2018--05:00
11 Aug 2018--09:00
12 Aug 2018--06:00
12 Aug 2018--06:00