I'm trying to scrape fundraising info using BeautifulSoup, and am running into trouble trying to isolate elements like the amount raised towards a fundraising goal.
Here is the code so far:
from bs4 import BeautifulSoup
import numpy as np
import pandas as pd
from time import sleep
import requests
import re
import json
page = requests.get("https://www.gofundme.com/f/eric-stevens-care-trust")
soup = BeautifulSoup(page.text, 'lxml')
Amount_raised = soup.find_all('h2', class_='m-progress-meter-heading')[0].get_text()
The code works, but when I view the result, it looks like this:
print(Amount_raised)
882,521 $ raised of 1,000,000 $ goal
Ideally, I would like to have just the number '882,521' returned or, even better, parse these into two variables, one with the amount raised and another with the fundraising goal.
I feel like there should be a way to either specify which element I want, or use regular expressions to isolate it, but my searches haven't been fruitful and I'm fairly new to python.
Edit: this is the section of HTML I am trying to work with
<h2 class="m-progress-meter-heading">882,521 $<!-- --> <span class="text-stat text-stat-title">raised of 1,000,000 $ goal</span>