Try to scrape withdrawal fee using Selenium. But doesn't work. (newbie)

Viewed 68

I try to scrape this website https://www.bitkub.com/fee/cryptocurrency using Selenium. I followed the tutorial from Youtube but It doesn't work. It can't find the element I wanted to use (coin_name, chain and withdrawal fees). I'm newbie to coding by the way. thank you in advance.

Here my code

from selenium import webdriver
website = 'https://www.bitkub.com/fee/cryptocurrency'
path = r"C:\\Users\\USER\\Downloads\\chromedriver.exe"
driver = webdriver.Chrome(path)
driver.get(website)

#pull_data

coins = driver.find_elements_by_tag_name('tr')

#variable
coin_name = []
chain = []
fee = []
for coin in coins:
    coin_name.append(coin.find_element_by_xpath('./td[2]').text)
    chain.append(coin.find_element_by_xpath('./td[3]').text)
    fee.append(coin.find_element_by_xpath('./td[4]').text)
#driver.quit()
2 Answers

#pull_data

coins = driver.find_elements_by_tag_name('tr')

#variable
data = []
for coin in coins:
    coin = {
    "coin_name":coin.find_element_by_xpath('./td[2]').text,
    "chain":coin.find_element_by_xpath('./td[3]').text,
    "fee" : coin.find_element_by_xpath('./td[4]').text
    }
    data.append(coin)

Try this this will create list of dictionaries and the convert this list to csv file

My new updated code. is it gonna work if I store all the data in one variable. But I wanted to export data to CSV using Pandas. That's why I'm trying to specify the element, So I can create a list out of it.

from selenium import webdriver
website = 'https://www.bitkub.com/fee/cryptocurrency'
path = r"C:\\Users\\USER\\Downloads\\chromedriver.exe"
driver = webdriver.Chrome(path)
driver.get(website)

#pull_data

coins = driver.find_elements_by_tag_name('tr')

#for_loop
for coin in coins:
    print(coin.text)
#driver.quit()
Related