简体   繁体   中英

I want to get some values of a table with selenium

i need to get with selenium, in python, the values of the first and second colum of this table and i don't know how do that -.-

This is a part of the table

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"]')

for tabla in tablas:
    fecha = tabla.find_element_by_class('first left bold noWrap').text
    precio = tabla.find_element_by_class('')

Iterate the list of element in for loop and get your desired column or whatever you want.

1.In inspect check column 1 and 2 index 2.get the list list of all columns 3.put a check inside your for loop where the index is 1 column and 2 column 4.Then with the help of getText get the values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM