|
@@ -164,9 +164,9 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
|
|
|
result.setLeagueId(leagueId);
|
|
result.setLeagueId(leagueId);
|
|
|
result.setCountryId(countryId);
|
|
result.setCountryId(countryId);
|
|
|
|
|
|
|
|
- firstResultsDiv = subDivs.get(2).findElement(By.xpath("./a"));
|
|
|
|
|
|
|
+ firstResultsDiv = subDivs.get(2); //.findElement(By.xpath("./a"));
|
|
|
} else if (subDivs.size() == 1) {
|
|
} else if (subDivs.size() == 1) {
|
|
|
- firstResultsDiv = subDivs.get(0).findElement(By.xpath("./a"));
|
|
|
|
|
|
|
+ firstResultsDiv = subDivs.get(0); //.findElement(By.xpath("./a"));
|
|
|
} else {
|
|
} else {
|
|
|
System.out.println("No games found!");
|
|
System.out.println("No games found!");
|
|
|
continue;
|
|
continue;
|
|
@@ -220,7 +220,7 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
|
|
|
|
|
|
|
|
private void setGameDate(ResultDTO result, WebElement firstResultsDiv) {
|
|
private void setGameDate(ResultDTO result, WebElement firstResultsDiv) {
|
|
|
final List<Integer> time = new ArrayList<>();
|
|
final List<Integer> time = new ArrayList<>();
|
|
|
- String datePath = "./div/div/div//p";
|
|
|
|
|
|
|
+ String datePath = "./div/a/div/div//p";
|
|
|
if (checkIfElementExists(firstResultsDiv, datePath)) {
|
|
if (checkIfElementExists(firstResultsDiv, datePath)) {
|
|
|
String timeText = firstResultsDiv.findElement(By.xpath(datePath)).getText();
|
|
String timeText = firstResultsDiv.findElement(By.xpath(datePath)).getText();
|
|
|
String[] timeSplit = timeText.split(":");
|
|
String[] timeSplit = timeText.split(":");
|
|
@@ -241,8 +241,8 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void setOdds(ResultDTO result, WebElement firstResultsDiv) {
|
|
private void setOdds(ResultDTO result, WebElement firstResultsDiv) {
|
|
|
- //List<WebElement> oddsDivs = firstResultsDiv.findElements(By.xpath("./div/div"));
|
|
|
|
|
- List<WebElement> oddsDivs = firstResultsDiv.findElements(By.xpath("./parent::*/div"));
|
|
|
|
|
|
|
+ List<WebElement> oddsDivs = firstResultsDiv.findElements(By.xpath("./div/div"));
|
|
|
|
|
+ //List<WebElement> oddsDivs = firstResultsDiv.findElements(By.xpath("./parent::*/div"));
|
|
|
try {
|
|
try {
|
|
|
result.setOdds1(Float.parseFloat(oddsDivs.get(0).getText()));
|
|
result.setOdds1(Float.parseFloat(oddsDivs.get(0).getText()));
|
|
|
result.setOddsX(Float.parseFloat(oddsDivs.get(1).getText()));
|
|
result.setOddsX(Float.parseFloat(oddsDivs.get(1).getText()));
|
|
@@ -256,26 +256,33 @@ public class OddsPortal extends ParserBase implements ParserJoinedFunctions {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Sets the scoring for the given result based on the provided WebElement.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param result the ResultDTO to set the scoring for
|
|
|
|
|
+ * @param firstResultsDiv the WebElement containing the scoring information
|
|
|
|
|
+ */
|
|
|
private void setScoring(ResultDTO result, WebElement firstResultsDiv) {
|
|
private void setScoring(ResultDTO result, WebElement firstResultsDiv) {
|
|
|
- // String resultPath = "./div/div/div[2]/div/div/div/div/div";
|
|
|
|
|
- //String resultPath = "./div/div/div[1]/div[2]/div/div/div/div/div";
|
|
|
|
|
- String resultPath = "./div/div[2]/div/div/div/div/div";
|
|
|
|
|
|
|
+ // XPath to locate the scoring information within the firstResultsDiv
|
|
|
|
|
+ String resultPath = "./div/a/div/div[2]/div/div/div/div/div";
|
|
|
|
|
|
|
|
|
|
+ // Check if the scoring element exists within the firstResultsDiv
|
|
|
if (checkIfElementExists(firstResultsDiv, resultPath)) {
|
|
if (checkIfElementExists(firstResultsDiv, resultPath)) {
|
|
|
|
|
+ // Find the scoring divs based on the resultPath
|
|
|
List<WebElement> scoringDivs = firstResultsDiv.findElements(By.xpath(resultPath));
|
|
List<WebElement> scoringDivs = firstResultsDiv.findElements(By.xpath(resultPath));
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // Set the home and away scores from the scoringDivs
|
|
|
result.setHomeScore(Integer.parseInt(scoringDivs.get(0).getText()));
|
|
result.setHomeScore(Integer.parseInt(scoringDivs.get(0).getText()));
|
|
|
result.setAwayScore(Integer.parseInt(scoringDivs.get(1).getText()));
|
|
result.setAwayScore(Integer.parseInt(scoringDivs.get(1).getText()));
|
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
|
- // There is no scoring yet continue processing
|
|
|
|
|
|
|
+ // If the scoring information is not available, continue processing
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void setTeamsInfo(ResultDTO result, WebElement firstResultsDiv) {
|
|
private void setTeamsInfo(ResultDTO result, WebElement firstResultsDiv) {
|
|
|
- String homeTeamName = firstResultsDiv.findElement(By.xpath(".//a[1]//p")).getText().trim();
|
|
|
|
|
- String awayTeamName = firstResultsDiv.findElement(By.xpath(".//a[2]//p")).getText().trim();
|
|
|
|
|
|
|
+ String homeTeamName = firstResultsDiv.findElement(By.xpath(".//a[1]/div/div[2]//p")).getText().trim();
|
|
|
|
|
+ String awayTeamName = firstResultsDiv.findElement(By.xpath(".//a[1]/div/div[2]/div/div/a[2]//p")).getText().trim();
|
|
|
|
|
|
|
|
result.setHomeTeam(homeTeamName);
|
|
result.setHomeTeam(homeTeamName);
|
|
|
result.setAwayTeam(awayTeamName);
|
|
result.setAwayTeam(awayTeamName);
|