正如title所说,我目前正试图获得一个动态的值。我迷失了,原来我用的是漂亮的汤,发现它的价值是动态的。以下是如何确定值的方法
.call({from: from})
.then(function(res) {
console.log("Node Price (Wei AVAX): " + res);
const avax = Number(Web3.utils.fromWei(res, 'ether'));
console.log("Node Price (AVAX): " + avax);
const items = document.querySelectorAll(".node-info-price-avax");
items.forEach(i => {
i.innerHTML = avax.toFixed(2) + " AVAX";
});
})下面是它的显示方式,
<span class="node-info-price-avax">27.88 AVAX</span>我已经看了一整天的教程和阅读指南,不能为我的爱找到如何获得上述价值。
发布于 2022-02-13 03:47:32
我找到了一段非常详细的视频,完全符合我的要求。解决方案是找到我需要的数据,并使用find_element复制xpath,然后我将它追加到列表中,并使用熊猫来使它看起来漂亮。以下是完成的代码:
from selenium import webdriver
import pandas as pd
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://playa3ull.games")
node_data = driver.find_elements_by_class_name('wpb_wrapper')
data_list = []
for data in node_data:
node_price = data.find_element_by_xpath('//*[@id="pb-node-info-table"]/tbody/tr[6]/td[2]/span[1]').text
nodes_sold = data.find_element_by_xpath('//*[@id="pb-node-info-table"]/tbody/tr[3]/td[2]').text
token_price = data.find_element_by_xpath('//*[@id="pb-node-info-table"]/tbody/tr[6]/td[2]/span[2]').text
data_item = {
'Node Price': node_price,
'Nodes Sold': nodes_sold,
'Token Price': token_price
}
data_list.append(data_item)
df = pd.DataFrame(data_list)
df_last = df[-1]
print(df_last)下面是更详细解释的链接:youtube.com/watch?v=lTypMlVBFM4 4
https://stackoverflow.com/questions/71097597
复制相似问题