I got this data with selenium in python, and i want to export it to excel.
I think i could use pandas but i don`t know how i do that. Thanks for your help.
This is my code:
import random
from time import sleep
from selenium import webdriver
driver = webdriver.Chrome('./chromedriver.exe')
driver.get('https://es.investing.com/crypto/bitcoin/btc-usd-historical-data?cid=1035793')
boton = driver.find_element_by_xpath('//button[@id="onetrust-accept-btn-handler"]')
boton.click()
sleep(random.uniform(5.0, 10.0))
lista = driver.find_element_by_xpath('//*[@id="data_interval"]/option[3]')
lista.click()
sleep(random.uniform(10.0, 20.0))
registro = driver.find_element_by_xpath('//*[@id="PromoteSignUpPopUp"]/div[2]/i')
registro.click()
sleep(random.uniform(8.0, 10.0))
tablas = driver.find_elements_by_xpath('//*[@id="curr_table"]')
rows = len(driver.find_elements_by_xpath('//*[@id="curr_table"]/tbody/tr'))
cols = len(driver.find_elements_by_xpath('//*[@id="curr_table"]/tbody/tr[1]/td'))
print(rows)
print(cols)
for n in range(2, rows+1):
for b in range(1, cols-4):
fec_pre = driver.find_element_by_xpath('//*[@id="curr_table"]/tbody/tr['+str(n)+']/td['+str(b)+']').text
print(fec_pre, end=' ')
print()