嘿,我正在尝试用python做一个btc价格检查器,我已经写了大部分,但是在这个网站上有一个指向图像的html,它是一个向上箭头或向下箭头,这是html代码。
<span class="icon-Caret-down"></span>所以在我的代码中,我会这样做
if class == str("icon-Caret-down"):
    print("Negative Percentage: -" + percentage")
else:
   print("Positive Percentage: " + percentage")"percentage“已经在我的代码中定义了
发布于 2021-06-05 06:45:19
我认为你需要bs4模块:
import bs4
if __name__ == "__main__":
    html = """<span class="icon-Caret-down"></span>"""
    soup = bs4.BeautifulSoup(html, "html.parser")
    for span in soup.find_all("span"):
        if span["class"][0] == "icon-Caret-down":
            # do stuffhttps://stackoverflow.com/questions/67844711
复制相似问题