【发布时间】:2021-06-15 13:55:44
【问题描述】:
我希望从link 中刮取硬币表并按日期创建一个 CSV 文件。对于每次新硬币更新,都应在现有数据文件的顶部创建一个新条目。
期望的输出
Coin,Pings,...Datetime
BTC,25,...07:17:05 03/18/21
我还没有走多远,但下面是我的尝试
from selenium import webdriver
import numpy as np
import pandas as pd
firefox = webdriver.Firefox(executable_path="/usr/local/bin/geckodriver")
firefox.get('https://agile-cliffs-23967.herokuapp.com/binance/')
rows = len(firefox.find_elements_by_xpath("/html/body/div/section[2]/div/div/div/div/table/tr"))
columns = len(firefox.find_elements_by_xpath("/html/body/div/section[2]/div/div/div/div/table/tr[1]/th"))
df = pd.DataFrame(columns=['Coin','Pings','Net Vol BTC','Net Vol per','Recent Total Vol BTC', 'Recent Vol per', 'Recent Net Vol', 'Datetime'])
for r in range(1, rows+1):
for c in range(1, columns+1):
value = firefox.find_element_by_xpath("/html/body/div/section[2]/div/div/div/div/table/tr["+str(r)+"]/th["+str(c)+"]").text
print(value)
# df.loc[i, ['Coin']] =
【问题讨论】:
标签: python selenium selenium-webdriver web-scraping geckodriver