Hej, kombinuje sobie z pythonem.
Mam skrypt do scrapowania danych ze strony:
Dla linku "https://www.betexplorer.com/soccer/england/premier-league-2019-2020/results/" działa bez zarzutu, dla https://www.betexplorer.com/hockey/new-zealand/nzihl/results/ totalnie nie. Nie widzę gdzie jest problem. Bedę wdzięczny za wskazówki.
import requests
from bs4 import BeautifulSoup
def parse_row(row):
if data := row.find_all("td"):
matchup = data[0].text
result = data[1].text
odds = []
for odds_cell in row.find_all("td", {"class": "table-main__odds"}):
if odds_cell.has_attr("data-odd"):
odds += [odds_cell["data-odd"]]
elif (odds_sub_cell := odds_cell.find(lambda tag: tag.has_attr("data-odd"))):
odds += [odds_sub_cell["data-odd"]]
date = data[-1].text
# Printing
print(
f"{matchup:>32s} {result:3s} {odds[0]:>5s} {odds[1]:>5s} {odds[2]:>5s} {date}")
# Main
#url = 'https://www.betexplorer.com/soccer/england/premier-league-2019-2020/results/'
url = 'https://www.betexplorer.com/hockey/new-zealand/nzihl/results/'
r = requests.get(url)
soup = BeautifulSoup(r.text, 'lxml')
table = soup.find(
'table', class_="table-main js-tablebanner-t js-tablebanner-ntb")
for row in table.find_all("tr")[1:]:
parse_row(row)