I got the problem with blank elements. I used to find elements in website selenium and I recived list with of elements but some of them are blank (exactly half).
Website: https://www.cmegroup.com/markets/energy/refined-products/gasoil-01-rotterdam-barges-swap.quotes.html
I'm looking for value from column name "MONTH", rest of columns work correctly (I recived list without empty values).
main = driver.find_element(By.ID, "main-content")
time.sleep(10)
matches = main.find_elements(By.XPATH,
'//*[@id="productTabData"]/div/div/div/div/div/div[2]/div/div/div/div/div/div[5]/div/div/div/div[1]/div/table/tbody/tr')
time.sleep(10)
dane = []
for match in matches:
Date = match.find_element(By.XPATH, "./td[1]/div/span/b").text
Price = match.find_element(By.XPATH, "./td[5]").text
Updated = match.find_element(By.XPATH, "./td[10]").text
print(Date)
table = {
"DataPL" : Date,
"GO" : Price,
"Updated" : Updated
}
dane.append(table)
df=pd.DataFrame(dane)
To solve problem I used .shift method(pandas) but I'm looking better solve
df["DataPL"] = df["DataPL"].shift(-18)
df = df.iloc[0:17,:2]