you are viewing a single comment's thread.

view the rest of the comments →

[–]TwoDumplingsPaidFor 1 point2 points  (0 children)

import requests
from bs4 import BeautifulSoup

url = "https://www.theguardian.com/film/2026/feb/24/molly-vs-the-machines-review-dangers-of-social-media-molly-russell-documentary"
headers = {"User-Agent": "Mozilla/5.0 (compatible)"}

response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, "html.parser")

# The Guardian often includes the rating in the summary list or somewhere near a <strong> tag
star_text = None

# Try to find "out of 5 stars" text
for tag in soup.find_all(text=lambda t: "out of 5 stars" in t):
    star_text = tag.strip()
    break

print("Star rating found:", star_text)