Python新手,我尝试使用beauthoulsoup从an中获取“ETH平衡”以太网扫描具有此代码的网页:
import bs4, requests
res = requests.get('https://etherscan.io/address/0x93673eeed88fda9423b8037374164383df54aec1')
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, 'html.parser')
ethBal = soup.find("td", text="ETH Balance").find_next("td").text
print('The ETH blance is '+ ethBal)
但是,我一直得到的错误是:
^{pr2}$我哪里出错了?怎样才能获得ETH平衡?在
我使用regex查找包含单词“Ether”的
td
,并解析了该标记。在代码:
输出:
^{pr2}$查看页面源代码,HTML是:
您正在搜索
text='ETH Balance'
。但是文本是ETH Balance:
,末尾有一个换行符。在所以,使用这个:
^{pr2}$相关问题 更多 >
编程相关推荐