Skip to content

Commit

Permalink
Updated URLCharityScraper
Browse files Browse the repository at this point in the history
Added method updateKeyNumbers() that gets the value of the 3 key number values by IK for the given charity.
  • Loading branch information
roaraf committed Apr 1, 2026
1 parent bc0cc72 commit 3232a98
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,50 @@ public boolean updateCategories() {

return true;
}

public boolean updateKeyNumbers() {
WebDriver driver = new ChromeDriver(options);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
String percentage;
WebElement element;

try {
driver.get("https://www.innsamlingskontrollen.no/organisasjoner/anna-ministries/");

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
"//li[.//h2[normalize-space()='Innsamlingsprosent']]//div[@class='graph']")));

element = driver.findElement(
By.xpath("//li[.//h2[normalize-space()='Innsamlingsprosent']]//div[@class='graph']")
);

percentage = element.getAttribute("data-percentage");
System.out.println(percentage);

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
"//li[.//h2[normalize-space()='Administrasjonsprosent']]//div[@class='graph']")));

element = driver.findElement(
By.xpath("//li[.//h2[normalize-space()='Administrasjonsprosent']]//div[@class='graph']")
);

percentage = element.getAttribute("data-percentage");
System.out.println(percentage);

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
"//li[.//h2[normalize-space()='Formålsprosent']]//div[@class='graph']")));

element = driver.findElement(
By.xpath("//li[.//h2[normalize-space()='Formålsprosent']]//div[@class='graph']")
);

percentage = element.getAttribute("data-percentage");
System.out.println(percentage);

} finally {
driver.quit();
}

return true;
}
}

0 comments on commit 3232a98

Please sign in to comment.