Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
oddspedia charts
#6
i've a problem tryng to scrapeing data from live matches

import requests
from bs4 import BeautifulSoup

url = "https://oddspedia.com/football"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'}
response = requests.get(url, headers=headers)

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

    # Trova tutti gli elementi div con la classe "match-status--inplay", "match-timer", o "match-score--inplay"
    matches = soup.find_all('div', class_=lambda value: value and ('match-status--inplay' in value or 'match-timer' in value or 'match-score--inplay' in value))

    for match in matches:
        # Trova l'elemento padre "a" contenente i dati desiderati
        match_info = match.find_parent('a')

        # Estrai i dati desiderati dalla struttura HTML
        match_url = match_info['href']
        teams = match_info.find_all('div', class_='match-team__name')
        team1 = teams[0].text.strip()
        team2 = teams[1].text.strip()

        # Estrai le immagini
        team_images = match_info.find_all('img', class_='logo-team')
        team1_image = team_images[0]['src']
        team2_image = team_images[1]['src']

        # Verifica se รจ presente il timer
        match_status = match.find('div', class_='match-status')
        match_timer = match.find('div', class_='match-timer')
        match_score = match.find('div', class_='match-score--inplay')

        status_text = match_status.text.strip() if match_status else "N/A"
        timer_text = match_timer.text.strip() if match_timer else "N/A"
        score_home = match_score.find('div', class_='match-score__team--home').text.strip() if match_score else "N/A"
        score_away = match_score.find('div', class_='match-score__team--away').text.strip() if match_score else "N/A"

        # Stampai dati 
        print(f"URL: {match_url}")
        print(f"Team 1: {team1}")
        print(f"Team 1 Image: {team1_image}")
        print(f"Team 2: {team2}")
        print(f"Team 2 Image: {team2_image}")
        print(f"Status: {status_text}")
        print(f"Timer: {timer_text}")
        print(f"Score Home: {score_home}")
        print(f"Score Away: {score_away}")
        print("----")

else:
    print(f"Errore nella richiesta. Codice di stato: {response.status_code}")
    print(response.text)  
no errors but no values
Reply


Messages In This Thread
oddspedia charts - by nicoali - Dec-05-2023, 08:53 AM
RE: oddspedia charts - by snippsat - Dec-05-2023, 01:32 PM
RE: oddspedia charts - by nicoali - Dec-05-2023, 04:44 PM
RE: oddspedia charts - by snippsat - Dec-05-2023, 06:20 PM
RE: oddspedia charts - by nicoali - Dec-05-2023, 08:08 PM
RE: oddspedia charts - by nicoali - Dec-07-2023, 04:47 PM
RE: oddspedia charts - by snippsat - Dec-07-2023, 06:51 PM
RE: oddspedia charts - by nicoali - Dec-07-2023, 08:01 PM
RE: oddspedia charts - by snippsat - Dec-08-2023, 03:09 PM
RE: oddspedia charts - by nicoali - Dec-08-2023, 06:09 PM
RE: oddspedia charts - by snippsat - Dec-08-2023, 09:25 PM
RE: oddspedia charts - by nicoali - Dec-09-2023, 02:59 PM
RE: oddspedia charts - by snippsat - Dec-09-2023, 11:36 PM
RE: oddspedia charts - by nicoali - Dec-10-2023, 10:00 AM
RE: oddspedia charts - by snippsat - Dec-10-2023, 11:27 AM
RE: oddspedia charts - by nicoali - Dec-10-2023, 11:40 AM
RE: oddspedia charts - by snippsat - Dec-10-2023, 04:38 PM
RE: oddspedia charts - by nicoali - Dec-11-2023, 08:26 AM
RE: oddspedia charts - by nicoali - Dec-11-2023, 04:44 PM
RE: oddspedia charts - by snippsat - Dec-11-2023, 10:57 PM
RE: oddspedia charts - by nicoali - Dec-15-2023, 10:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Configuration file through helm charts saisankalpj 0 1,770 Aug-23-2022, 01:32 PM
Last Post: saisankalpj
  Cannot Extract data through charts online AgileAVS 0 1,880 Feb-01-2020, 01:47 PM
Last Post: AgileAVS

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020