diff --git a/main.py b/main.py index 760024a..564723d 100644 --- a/main.py +++ b/main.py @@ -125,13 +125,31 @@ def schedule(): source = requests.get(link).text page = BeautifulSoup(source, "lxml") page = page.find_all("div",class_="cb-col-100 cb-col") - first = page[0].find_all("div",class_="cb-col-100 cb-col") - matches = [] - for i in range(len(first)): - matches.append(first[i].text) - - - return jsonify(matches) + matches_all = [] + + for container in page: + match_details = container.find_all('div', class_='cb-ovr-flo cb-col-50 cb-col cb-mtchs-dy-vnu cb-adjst-lst') + + for match in match_details: + matches_one = {} + title = match.find('a')['title'] + date_div = container.find('div', class_='cb-lv-grn-strip text-bold') + if date_div: + date = date_div.text.strip() + venue = match.find('div', class_='cb-font-12 text-gray cb-ovr-flo').text.strip() + time_div = match.find_next('div', class_='cb-col-50 cb-col cb-mtchs-dy-tm cb-adjst-lst') + if time_div: + time = time_div.find('div', class_='cb-font-12 text-gray').text.strip() + else: + time = "Time not available" + + matches_one['match'] = title + matches_one['date'] = date + matches_one['venue'] = venue + matches_one['time'] = time + matches_all.append(matches_one) + + return jsonify(matches_all) @app.route('/live')