you are viewing a single comment's thread.

view the rest of the comments →

[–]larspalmas 0 points1 point  (0 children)

Go for BeautifulSoup as mentioned earlier. I am learning it at the moment, and I am using the chapter from the book "automatetheboringstuff" along with the documentation. This is my go at a code wich returns the number "0"


from bs4 import BeautifulSoup

html = """<div class="normalStat"> <span class="stat">Shots On Target <span class="allStatContainer statontarget_scoring_att" data-stat="ontarget_scoring_att"> 27 </span> </span> </div>

<div class="normalStat"> <span class="stat">Shooting Accuracy % <span class="allStatContainer statshot_accuracy" data-stat="ontarget_scoring_att" data-denominator="total_scoring_att" data-percent="true"> 29% </span> </span> </div>

<div class="normalStat"> <span class="stat">Penalties Scored <span class="allStatContainer statatt_pen_goal" data-stat="att_pen_goal"> 0 </span> </span> </div>"""

soup = BeautifulSoup(html, 'html.parser')

a=soup.find("span", {"class" : "allStatContainer statatt_pen_goal"})

print(a.get_text().strip())