private void getFights ( Document doc , Event event ) { logger . info ( "Getting fights for event #{}[{}]" , event . getSherdogUrl ( ) , event . getName ( ) ) ; SherdogBaseObject sEvent = new SherdogBaseObject ( ) ; sEvent . setName ( event . getName ( ) ) ; sEvent . setSherdogUrl ( event . getSherdogUrl ( ) ) ; List < Fight > fights = new ArrayList <> ( ) ; //Checking on main event Elements mainFightElement = doc . select ( ".content.event" ) ; Elements fighters = mainFightElement . select ( "h3 a" ) ; //First fighter SherdogBaseObject mainFighter1 = new SherdogBaseObject ( ) ; Element mainFighter1Element = fighters . get ( 0 ) ; mainFighter1 . setSherdogUrl ( mainFighter1Element . attr ( "abs:href" ) ) ; mainFighter1 . setName ( mainFighter1Element . select ( "span[itemprop=\"name\"]" ) . html ( ) ) ; //second fighter SherdogBaseObject mainFighter2 = new SherdogBaseObject ( ) ; Element mainFighter2Element = fighters . get ( 1 ) ; mainFighter2 . setSherdogUrl ( mainFighter2Element . attr ( "abs:href" ) ) ; mainFighter2 . setName ( mainFighter2Element . select ( "span[itemprop=\"name\"]" ) . html ( ) ) ; Fight mainFight = new Fight ( ) ; mainFight . setEvent ( sEvent ) ; mainFight . setFighter1 ( mainFighter1 ) ; mainFight . setFighter2 ( mainFighter2 ) ; mainFight . setResult ( ParserUtils . getFightResult ( mainFightElement . first ( ) ) ) ; //getting method Elements mainTd = mainFightElement . select ( "td" ) ; if ( mainTd . size ( ) > 0 ) { mainFight . setWinMethod ( mainTd . get ( 1 ) . html ( ) . replaceAll ( "<em(.*)<br>" , "" ) . trim ( ) ) ; mainFight . setWinRound ( Integer . parseInt ( mainTd . get ( 3 ) . html ( ) . replaceAll ( "<em(.*)<br>" , "" ) . trim ( ) ) ) ; mainFight . setWinTime ( mainTd . get ( 4 ) . html ( ) . replaceAll ( "<em(.*)<br>" , "" ) . trim ( ) ) ; } mainFight . setDate ( event . getDate ( ) ) ; fights . add ( mainFight ) ; logger . info ( "Fight added: {}" , mainFight ) ; //Checking on card results logger . info ( "Found {} fights" , fights . size ( ) ) ; Elements tds = doc . select ( ".event_match table tr" ) ; fights . addAll ( parseEventFights ( tds , event ) ) ; event . setFights ( fights ) ; }
Gets the fight of the event