Skip to content

Commit

Permalink
Updated IKOrganizationScraper
Browse files Browse the repository at this point in the history
Changed some of the logic in updateData() to prepare for format for writing to csv file.
  • Loading branch information
roaraf committed Feb 24, 2026
1 parent bf7327e commit 7e7696a
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public boolean updateData() {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("table")));

// Loops through table rows and columns
List<WebElement> rows = driver.findElements(By.cssSelector("table tbody tr"));

String name = null;
String telephone = null;
String location = null;
Expand All @@ -47,28 +44,38 @@ public boolean updateData() {
// Clear old data before updating
this.organizationData.clear();

for (WebElement row : rows) {
List<WebElement> columns = row.findElements(By.tagName("td"));
// Loops through table rows and columns
List<WebElement> rows = driver.findElements(By.cssSelector("table tbody tr"));

for (int i = 0; i < rows.size(); i++) {
List<WebElement> columns = rows.get(i).findElements(By.tagName("td"));

for (int i = 0; i < columns.size(); i++) {
// Create organization with category names for csv file
if (i == 0) {
var categories = new Organization("Name", "Telephone", "Location", "Status");
this.organizationData.add(categories);
continue;
}

WebElement column = columns.get(i);
for (int j = 0; j < columns.size(); j++) {

WebElement column = columns.get(j);

// Non-verification columns
if (i == 0) {
if (j == 0) {
name = column.getText();
}

if (i == 1) {
telephone = columns.get(i).getText();
if (j == 1) {
telephone = columns.get(j).getText();
}

if (i == 2) {
location = columns.get(i).getText();
if (j == 2) {
location = columns.get(j).getText();
}

// Verification column
if (i == 3) {
if (j == 3) {
if (!column.findElements(By.cssSelector(".status-pre-approved")).isEmpty()) {
status = "Monitored";
} else if (!column.findElements(By.cssSelector(".status-approved")).isEmpty()) {
Expand All @@ -84,9 +91,6 @@ public boolean updateData() {
}
driver.quit();

// Removes the first empty row that lists only the categories, aka no relevant data
this.organizationData.removeFirst();

return true;
}

Expand Down

0 comments on commit 7e7696a

Please sign in to comment.