Nov-11-2023, 08:19 AM
Hello,
I am extracting football results with their odds, I have created 2 for-loops, one for the extraction of team names and results and one for the odds. Every single for loop works well, but I don't know how I can combine them together to get the correct output.
This is my code:
You can see that I get the same odds for each match, and it's not correct.
My goal is the follow output (this is a little part):
is it also possible to have odds without square brackets?
Thanks
I am extracting football results with their odds, I have created 2 for-loops, one for the extraction of team names and results and one for the odds. Every single for loop works well, but I don't know how I can combine them together to get the correct output.
This is my code:
from requests_html import HTMLSession import tabulate from tabulate import tabulate matchlink = 'https://www.betexplorer.com/football/england/league-one/results/' session = HTMLSession() r = session.get(matchlink) allmatch = r.html.find('.in-match') results = r.html.find('.h-text-center a') matchodds = r.html.find('.table-main__odds') odds = [matchodd.text for matchodd in matchodds] for match, res in zip(allmatch, results): #works for i in range(0, len(odds), 3): if res.text == 'POSTP.': continue print(match.text, res.text, odds[i:i+3])My actual output is (this is a little part):
Quote:Wigan - Peterborough 2:1 ['2.09', '3.45', '3.37']
Reading - Bristol Rovers 1:1 ['2.09', '3.45', '3.37']
Shrewsbury - Bolton 0:2 ['2.09', '3.45', '3.37']
Fleetwood - Blackpool 3:3 ['2.09', '3.45', '3.37']
Derby - Northampton 4:0 ['2.09', '3.45', '3.37']
Lincoln - Oxford Utd 0:2 ['2.09', '3.45', '3.37']
You can see that I get the same odds for each match, and it's not correct.
My goal is the follow output (this is a little part):
Quote:Wigan - Peterborough 2:1 ['2.97', '3.57', '2.23']
Reading - Bristol Rovers 1:1 ['2.57', '3.51', '2.54']
Shrewsbury - Bolton 0:2 ['3.71', '3.47', '1.98']
Fleetwood - Blackpool 3:3 ['3.26', '3.25', '2.22']
Derby - Northampton 4:0 ['1.54', '3.91', '6.24']
Lincoln - Oxford Utd 0:2 ['3.28', '3.18', '2.25']
is it also possible to have odds without square brackets?
Thanks