仮想通貨でTombというトークンがあり、そのプライスをゲットしたいです。こちらのサイトにいけば6時間ごと変わっていく価格が出てきます。
https://ftmscan.com/address/0x8764DE60236C5843D9faEB1B638fbCE962773B67#readContract
こちらの7のgetTombPriceがその価格です。
この質問を書いている時点では価格は1010526190555921067のはずです。 下記のコードだとNoneと出てきます。
Python v3
1from bs4 import BeautifulSoup 2import requests 3import os 4 5URL = 'https://ftmscan.com/address/0x8764DE60236C5843D9faEB1B638fbCE962773B67#readContract' 6page = requests.get(URL).text 7soup = BeautifulSoup(page, "html.parser") 8 9contents = soup.find('div', class_="form-group") 10print(contents)
違うやり方で書いてみました。今度はxpathをコピーしてprintしてみましたが、今度は[ ] と出てきます。
Python
1from bs4 import BeautifulSoup 2import requests 3import os 4from lxml import etree 5 6URL = 'https://ftmscan.com/address/0x8764DE60236C5843D9faEB1B638fbCE962773B67#readContract' 7page = requests.get(URL).text 8soup = BeautifulSoup(page, "html.parser") 9 10dom = etree.HTML((str(soup))) 11print(dom.xpath('//*[@id="readCollapse7"]/div/form/div/text()'))
何が間違っているのでしょうか?どなたか助けて頂けると非常に助かります (><)
宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/04/12 01:26
2022/04/12 06:01
2022/04/12 08:21