فهرست منبع

Another oddsPortal Uppdate

Axel Nordh 2 سال پیش
والد
کامیت
f31980f07d
4فایلهای تغییر یافته به همراه121 افزوده شده و 98 حذف شده
  1. 1 1
      Odds/src/main/Main.java
  2. 28 5
      Odds/src/parser/OddsPortal.java
  3. 90 89
      OddsJavaFx/pom.xml
  4. 2 3
      OddsJavaFx/src/controllers/MainController.java

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

@@ -53,7 +53,7 @@ public class Main {
         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");
+        System.out.println("Getting Tomorrows matches");
         op.getMatches(LocalDateTime.now().plusDays(1));
         System.out.println("Getting Next days matches");
         op.getMatches(LocalDateTime.now().plusDays(2));

+ 28 - 5
Odds/src/parser/OddsPortal.java

@@ -152,7 +152,30 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
                 ResultDTO result = new ResultDTO(SOCCER_RESULTS_TABLE_NAME);
 
                 boolean somethingWrong = false;
+
                 List<WebElement> subDivs = element.findElements(By.xpath("./div"));
+
+                if (subDivs.size() == 2) {
+                    WebElement competitionsDiv = subDivs.get(0);
+                    List<WebElement> links = competitionsDiv.findElements(By.xpath(".//a"));
+                    countryId = getCountryId(links);
+                    leagueId = getLeagueId(links);
+                    result.setLeagueId(leagueId);
+                    result.setCountryId(countryId);
+                }
+
+                WebElement firstResultsDiv = element.findElement(By.xpath("./a"));
+
+                setGameDate(result, firstResultsDiv);
+
+                setTeamsInfo(result, firstResultsDiv);
+
+                setScoring(result, firstResultsDiv);
+
+                setOdds(result, firstResultsDiv);
+
+                /*
+
                 if (subDivs.size() == 3) {
                     WebElement competitionsDiv = subDivs.get(0);
                     List<WebElement> links = competitionsDiv.findElements(By.xpath(".//a"));
@@ -189,7 +212,7 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
                     String message = "Subdiv size = " + subDivs.size();
                     Logger.getGlobal().log(Level.WARNING, message);
                 }
-
+                 */
                 if (!somethingWrong) {
                     final Mysql mysql = Mysql.getInstance();
 
@@ -230,8 +253,8 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
 
     private void setGameDate(ResultDTO result, WebElement firstResultsDiv) {
         final List<Integer> time = new ArrayList<>();
-        // String datePath = "./div/a/div[1]/div/p";
-        String datePath = "./div/div/div/div/div/p";
+        //String datePath = "./div/div/div/div/div/p";
+        String datePath = "./div/div/div//p";
         if (checkIfElementExists(firstResultsDiv, datePath)) {
             String timeText = firstResultsDiv.findElement(By.xpath(datePath)).getText();
             String[] timeSplit = timeText.split(":");
@@ -283,8 +306,8 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
     }
 
     private void setTeamsInfo(ResultDTO result, WebElement firstResultsDiv) {
-        String homeTeamName = firstResultsDiv.findElement(By.xpath(".//a[1]/div")).getText().trim();
-        String awayTeamName = firstResultsDiv.findElement(By.xpath(".//a[2]/div")).getText().trim();
+        String homeTeamName = firstResultsDiv.findElement(By.xpath(".//a[1]//p")).getText().trim();
+        String awayTeamName = firstResultsDiv.findElement(By.xpath(".//a[2]//p")).getText().trim();
 
         result.setHomeTeam(homeTeamName);
         result.setAwayTeam(awayTeamName);

+ 90 - 89
OddsJavaFx/pom.xml

@@ -1,91 +1,92 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>Odds</groupId>
-  <artifactId>OddsFx</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>Odds</groupId>
+    <artifactId>OddsFx</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
     <properties>
-    <maven.compiler.source>18</maven.compiler.source>
-    <maven.compiler.target>18</maven.compiler.target>
-  </properties>
-  <repositories>
-    <repository>
-      <id>nordhs-repo</id>
-      <name>Nords Repo</name>
-      <url>http://nordh.xyz:9099/repository/nordhs-repo/</url>
-    </repository>
-  </repositories>
-  <build>
-    <sourceDirectory>src</sourceDirectory>
-    <plugins>
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.10.1</version>
-      </plugin>
-	        <plugin>
-        <groupId>org.openjfx</groupId>
-          <artifactId>javafx-maven-plugin</artifactId>
-          <version>0.0.6</version>
-          <executions>
-              <execution>
-                  <!-- Default configuration for running -->
-                  <!-- Usage: mvn clean javafx:run -->
-                  <id>default-cli</id>
-                  <configuration>
-                      <mainClass>application.Main</mainClass>
-                  </configuration>
-              </execution>
-          </executions>
-        </plugin>
-    </plugins>
-    <resources>
-      <resource>
-        <directory>src/fxml/</directory>
-        <includes>
-          <include>**/*.fxml</include>
-        </includes>
-      </resource>
-    </resources>
-  </build>
-  <dependencies>
-    <dependency>
-      <groupId>Odds</groupId>
-      <artifactId>Odds</artifactId>
-      <version>Odds-0.0.1-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-	    <groupId>com.google.guava</groupId>
-	    <artifactId>guava</artifactId>
-	    <version>30.0-jre</version>
-	  </dependency>
-    <dependency>
-      <groupId>net.sourceforge.htmlunit</groupId>
-        <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>
-        <version>3.0</version>
-    </dependency>
-		<dependency>
-	    <groupId>com.google.code.gson</groupId>
-	    <artifactId>gson</artifactId>
-	    <version>2.9.0</version>
-	  </dependency>
-  	<dependency>
-	    <groupId>org.openjfx</groupId>
-	    <artifactId>javafx-controls</artifactId>
-	    <version>19-ea+8</version>
-	  </dependency>
-	  <dependency>
-	      <groupId>org.openjfx</groupId>
-	      <artifactId>javafx-fxml</artifactId>
-	      <version>19-ea+8</version>
-	  </dependency>
-   </dependencies>
+        <maven.compiler.source>18</maven.compiler.source>
+        <maven.compiler.target>18</maven.compiler.target>
+    </properties>
+    <repositories>
+        <repository>
+            <id>nordhs-repo</id>
+            <name>Nords Repo</name>
+            <url>http://nordh.xyz:9099/repository/nordhs-repo/</url>
+        </repository>
+    </repositories>
+    <build>
+        <sourceDirectory>src</sourceDirectory>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.10.1</version>
+            </plugin>
+            <plugin>
+                <groupId>org.openjfx</groupId>
+                <artifactId>javafx-maven-plugin</artifactId>
+                <version>0.0.6</version>
+                <executions>
+                    <execution>
+                        <!-- Default configuration for running -->
+                        <!-- Usage: mvn clean javafx:run -->
+                        <id>default-cli</id>
+                        <configuration>
+                            <mainClass>application.Main</mainClass>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <resources>
+            <resource>
+                <directory>src/fxml/</directory>
+                <includes>
+                    <include>**/*.fxml</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>Odds</groupId>
+            <artifactId>Odds</artifactId>
+            <version>Odds-0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.htmlunit</groupId>
+            <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>
+            <version>3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.9.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.openjfx</groupId>
+            <artifactId>javafx-controls</artifactId>
+            <version>19-ea+8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.openjfx</groupId>
+            <artifactId>javafx-fxml</artifactId>
+            <version>19-ea+8</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>31.1-jre</version>
+        </dependency>
+    </dependencies>
 </project>

+ 2 - 3
OddsJavaFx/src/controllers/MainController.java

@@ -11,8 +11,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.ResourceBundle;
 
-import org.eclipse.jetty.util.log.Log;
-
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
@@ -29,6 +27,7 @@ import javafx.scene.control.ComboBox;
 import javafx.scene.control.TextField;
 import javafx.scene.layout.Pane;
 import objects.SoccerMatch;
+import org.eclipse.jetty.util.log.Log;
 import parser.OddsPortal;
 
 public class MainController implements Initializable {
@@ -246,7 +245,7 @@ public class MainController implements Initializable {
 			val--;
 			nextParseYear = String.valueOf(val);
 		} else {
-			Log.getLog().info("Fail to get More league info for %s", lastParsedYear);
+			Log.getLogger("getMoreLeagueInfo").info("Fail to get More league info for %s", lastParsedYear);
 			return;
 		}