Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def jornada_float(jornada):
- try:
- int(jornada)
- return True
- except ValueError:
- return False
- def get_jornada(jornada, equipo=None):
- matchInfoRegexp = "(\d{1,2}) (.*), (\d{4}) \xb7 ((\d{1,2}:\d{1,2}) (am|pm))(.*?)"
- web = urllib.request.urlopen('http://antoniovela.es/ligafcmv/756-2/?league_id=4&match_day_4=' + str(jornada)).read()
- soup = BeautifulSoup(web, "html.parser")
- matchTable = soup.find('table', {'class':['leaguemanager', 'matchtable']});
- text = "🔫"
- text += "<b>Torneo FCMV - Jornada " + str(jornada) + "</b>"
- text += "🔫"
- text += "\n\n"
- if(matchTable):
- teamFound = (equipo is None);
- matches = matchTable.findAll('td', {'class': 'match'})
- for match in matches:
- matchTime = ""
- matchDate = ""
- matchInfo = match.find('br').previousSibling
- matchTeams = match.find('strong');
- matchScore = match.parent.find('td', {'class':'score'});
- regMatch = re.search(matchInfoRegexp, matchInfo)
- if(regMatch):
- matchTime = regMatch.group(4).rjust(8, '0');
- matchDate = regMatch.group(1) + " " + regMatch.group(2) + " " + regMatch.group(3);
- if(matchInfo and matchTeams and matchScore):
- if((equipo is None) or (matchTeams.text.lower().find(equipo.lower()) > -1)):
- text += "🗓" + " "
- text += matchTime.strip()
- text += " - "
- text += matchDate.strip()
- text += "\n"
- text += "âš”" + " "
- text += "<i>" + matchTeams.text.strip() + "</i>"
- text += "\n"
- text += "âš–" + " "
- text += "<b>" + matchScore.text.strip() + "</b>"
- text += "\n\n"
- teamFound = True;
- if(teamFound == False):
- text += "Equipo no encontrado";
- text += "\n";
- else:
- text += "Jornada no encontrada";
- text += "\n";
- text += "\n" + 'Mas en <a href="http://www.ligafcmv.tk/">LIGAFCMV</a>'
- return(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement