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()
CodePudding user response:
its gong to be difficult to scrape that site because its clooudflare protected. You can try This ChromeDriver to bypass this cloudflare protection. I am not sure it will work or not now
And you you need to use Waits . which will allow chrome to load the webpages then execute the next step. As the table of that site is loading dynamically you need to use WAITS . But for this site you need to bypass the cloudflare protection first
CodePudding user response:
My new updated code. is it gonna work if I store all the data in one variable.
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()
