Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.0 kB
3
Indexable
Never
import requests
from bs4 import BeautifulSoup

url = 'https://vitb-placements.vercel.app/'  # Replace with the actual URL of the page you want to scrape
response = requests.get(url)

if response.status_code == 200:
    soup = BeautifulSoup(response.text, 'html.parser')

    # Find all elements with class "Home_column__K2U98"
    elements = soup.find_all('p', class_='Home_column__K2U98')

    # Find corresponding CGPA elements
    cgpa_elements = soup.find_all('span', {'class': 'Home_detailsBold__bUV_G', 'text': 'UG: '})
    cgpa_values = [float(cgpa.find_next_sibling('span').get_text(strip=True)) for cgpa in cgpa_elements]

    # Filter elements based on CGPA condition (>= 8.5)
    filtered_elements = [element for element, cgpa in zip(elements, cgpa_values) if cgpa >= 8.5]

    # Print the filtered elements
    for element in filtered_elements:
        print(element.get_text(strip=True))
else:
    print(f"Failed to fetch the webpage. Status code: {response.status_code}")
Leave a Comment