I am currently trying to scrape some data from a webpage. The data I need is within the <meta> tag of the html source. Scraping the data and saving it to a String with BeautifulSoup is no problem.
The String contains 2 numbers I want to extract. Each of those numbers (review scores from 1-100) should be assigned to a distinct variable for further processing.
test_str = "<meta content=\"Overall Rating: 79/100 ... Some Info ... Score: 86/100 \"/>"
The first value is 79/100 and the second is 86/100, but I only need 79 and 86. So far I have created a regex search to find those values and then .replace("/100") to clean things up.
But with my code, I only get the value for the first regex search match, which is 79. I tried getting the second value with m.group(1) but it doesn't work.
What am I missing ?
test_str = "<meta content=\"Overall Rating: 79/100 ... Some Info ... Score: 86/100 \"/>"
m = re.search("../100", test_str)
if m:
found = m.group(0).replace("/100","")
print found
# output -> 79
Thanks for your help.
Best regards!
re.findallreturn an array of matchesmeta_description = soup.find("meta", {"name": "rating-data"}). I just didn't include the part of BeautifulSoup to keep things simple.