【发布时间】:2021-11-03 04:07:07
【问题描述】:
我正在尝试从以下网站获取特定数据。只有一种形式是“令牌地址”。但我不知道如何提取“Buy Tax:”和“Sell Tax:”之后显示的数字。我只需要没有百分号的数字。使用 Python 提取此信息的最简洁方法是什么?
我的失败尝试:
xPath_buy = /html/body/div/div[1]/div/p[5]/text()[1]
xPath_sell = /html/body/div/div[1]/div/p[5]/text()[2]
token = "0x40619dc9f00ea34e51d96b6ec5d8a6ad75457434"
url = "https://honeypot.is/?address=" + token
def tax(token):
url = "https://honeypot.is/?address=" + token
HTML = requests.get (url)
soup = BeautifulSoup(HTML.text, 'html.parser')
text = soup.find('div style', attrs={'xpath': '//*[@id="shitcoin"]/div/p[5]/text()[1]'})
return text
buy_tax = tax(token)
print(buy_tax)
【问题讨论】:
-
js计算:见view-source:honeypot.is/?address=0x40619dc9f00ea34e51d96b6ec5d8a6ad75457434(第250行)
标签: python html python-requests