Axel Nordh 2 лет назад
Родитель
Сommit
f4fdc369bf

+ 5 - 5
Odds/pom.xml

@@ -77,11 +77,11 @@
       <artifactId>RCaller</artifactId>
       <version>3.0</version>
     </dependency>
-    <dependency>
-        <groupId>mysql</groupId>
-        <artifactId>mysql-connector-java</artifactId>
-        <version>8.0.30</version>
-    </dependency>
+      <dependency>
+          <groupId>com.mysql</groupId>
+          <artifactId>mysql-connector-j</artifactId>
+          <version>8.0.33</version>
+      </dependency>
     <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>

+ 6 - 6
Odds/src/main/Main.java

@@ -51,12 +51,12 @@ public class Main {
 
         System.out.println("Getting One days ago matches");
         op.getMatches(LocalDateTime.now().plusDays(-1));
-        System.out.println("Getting Today days ago matches");
-        op.getMatches(LocalDateTime.now().plusDays(0));
-        System.out.println("Getting Tomorrow days matches");
-        op.getMatches(LocalDateTime.now().plusDays(1));
-        System.out.println("Getting Next days matches");
-        op.getMatches(LocalDateTime.now().plusDays(2));
+//        System.out.println("Getting Today days ago matches");
+//        op.getMatches(LocalDateTime.now().plusDays(0));
+//        System.out.println("Getting Tomorrow days matches");
+//        op.getMatches(LocalDateTime.now().plusDays(1));
+//        System.out.println("Getting Next days matches");
+//        op.getMatches(LocalDateTime.now().plusDays(2));
 
     }
 

+ 24 - 11
Odds/src/parser/OddsPortal.java

@@ -14,9 +14,12 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.openqa.selenium.By;
+import org.openqa.selenium.Platform;
 import org.openqa.selenium.StaleElementReferenceException;
 import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
 import org.openqa.selenium.chrome.ChromeOptions;
+import org.openqa.selenium.remote.DesiredCapabilities;
 import org.openqa.selenium.remote.RemoteWebDriver;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.support.ui.WebDriverWait;
@@ -232,8 +235,10 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
 
     private void setGameDate(ResultDTO result, WebElement firstResultsDiv) {
         final List<Integer> time = new ArrayList<>();
-        if (checkIfElementExists(firstResultsDiv, "./div/a/div[1]/div/p")) {
-            String timeText = firstResultsDiv.findElement(By.xpath("./div/a/div[1]/div/p")).getText();
+        // String datePath = "./div/a/div[1]/div/p";
+        String datePath = "./div/div/div/div/p";
+        if (checkIfElementExists(firstResultsDiv, datePath)) {
+            String timeText = firstResultsDiv.findElement(By.xpath(datePath)).getText();
             String[] timeSplit = timeText.split(":");
             if (timeSplit.length == 2) {
                 time.add(Integer.parseInt(timeSplit[0]));
@@ -254,12 +259,16 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
     }
 
     private void setOdds(ResultDTO result, WebElement firstResultsDiv) {
-        List<WebElement> oddsDivs = firstResultsDiv.findElements(By.xpath("./div/div"));
+        List<WebElement> oddsDivs = firstResultsDiv.findElements(By.xpath("./div"));
 
         try {
-            result.setOdds1(Float.parseFloat(oddsDivs.get(0).getText()));
-            result.setOddsX(Float.parseFloat(oddsDivs.get(1).getText()));
-            result.setOdds2(Float.parseFloat(oddsDivs.get(2).getText()));
+//            result.setOdds1(Float.parseFloat(oddsDivs.get(0).getText()));
+//            result.setOddsX(Float.parseFloat(oddsDivs.get(1).getText()));
+//            result.setOdds2(Float.parseFloat(oddsDivs.get(2).getText()));
+
+            result.setOdds1(Float.parseFloat(oddsDivs.get(1).getText()));
+            result.setOddsX(Float.parseFloat(oddsDivs.get(2).getText()));
+            result.setOdds2(Float.parseFloat(oddsDivs.get(3).getText()));
         } catch (NumberFormatException e) {
             // Skip this one
         } catch (IndexOutOfBoundsException e) {
@@ -269,8 +278,11 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
     }
 
     private void setScoring(ResultDTO result, WebElement firstResultsDiv) {
-        if (checkIfElementExists(firstResultsDiv, "./div/a/div[2]/div/div/div/div/div")) {
-            List<WebElement> scoringDivs = firstResultsDiv.findElements(By.xpath("./div/a/div[2]/div/div/div/div/div"));
+//        String resultPath = "./div/a/div[2]/div/div/div/div/div";
+        String resultPath = "./div/div[2]/div/div/div/div/div";
+
+        if (checkIfElementExists(firstResultsDiv, resultPath)) {
+            List<WebElement> scoringDivs = firstResultsDiv.findElements(By.xpath(resultPath));
             try {
                 result.setHomeScore(Integer.parseInt(scoringDivs.get(0).getText()));
                 result.setAwayScore(Integer.parseInt(scoringDivs.get(2).getText()));
@@ -282,9 +294,10 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
     }
 
     private void setTeamsInfo(ResultDTO result, WebElement firstResultsDiv) {
-        List<WebElement> teams = firstResultsDiv.findElements(By.xpath(".//div//a//div[2]//a"));
-        String homeTeamName = teams.get(0).getText().trim();
-        String awayTeamName = teams.get(1).getText().trim();
+        //List<WebElement> teams = firstResultsDiv.findElements(By.xpath(".//div//a//div[2]//a"));
+        List<WebElement> teams = firstResultsDiv.findElements(By.xpath(".//a"));
+        String homeTeamName = teams.get(0).findElement(By.xpath("/div[1]")).getText().trim();
+        String awayTeamName = teams.get(1).findElement(By.xpath("/div[1]")).getText().trim();
         result.setHomeTeam(homeTeamName);
         result.setAwayTeam(awayTeamName);
 

+ 5 - 0
OddsJavaFx/pom.xml

@@ -62,6 +62,11 @@
         <artifactId>htmlunit</artifactId>
         <version>2.50.0</version>
     </dependency>
+      <dependency>
+          <groupId>com.mysql</groupId>
+          <artifactId>mysql-connector-j</artifactId>
+          <version>8.0.33</version>
+      </dependency>
     <dependency>
         <groupId>com.github.jbytecode</groupId>
         <artifactId>RCaller</artifactId>

+ 1 - 1
OddsJavaFx/src/parser/OddsPortal.java

@@ -235,7 +235,7 @@ public class OddsPortal implements ParserJoinedFunctions {
                             awayScore, overtime, odds1, oddsX, odds2, countryId, season, leagueId, sportId));
                 }
             }
-        } catch (FailingHttpStatusCodeException | IOException e) {
+        } catch (FailingHttpStatusCodeException | IOException | SQLException e) {
             e.printStackTrace();
         }
     }