RELIABILITY FIX
All checks were successful
Build and Push Quarkus Image / build-and-push (push) Successful in 4m59s

This commit is contained in:
2026-03-02 21:27:45 +01:00
parent 5b0219404a
commit 2676a73f29

View File

@@ -1,7 +1,9 @@
package nl.veenm.jobfindr.scrapers;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import nl.veenm.jobfindr.domain.Vacature;
import nl.veenm.jobfindr.util.EventService;
import org.jboss.logging.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@@ -13,15 +15,20 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ApplicationScoped
public class ScraperService {
private static final Logger log = Logger.getLogger(ScraperService.class);
private final EventService eventService;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
@Inject
public ScraperService(EventService eventService) {
this.eventService = eventService;
}
public List<Vacature> scrapeVacatures(String url) throws IOException {
// Maak verbinding met de website
Document doc = Jsoup.connect(url).get();
@@ -42,9 +49,15 @@ public class ScraperService {
link = "https://www.meesterbaan.nl" + link;
}
assert vacatureElement.parent() != null;
Element locationElement = vacatureElement.parent().selectFirst("div.location.mt-1");
String location = locationElement != null ? locationElement.text() : "Onbekende locatie";
String location = "Onbekende locatie";
Element parent = vacatureElement.parent();
if (parent != null) {
Element locationElement = parent.selectFirst("div.location.mt-1");
if (locationElement != null) {
location = locationElement.text();
}
}
// Maak een Vacature-object en voeg het toe aan de lijst
vacatures.add(new Vacature(title, link, location));
@@ -54,11 +67,11 @@ public class ScraperService {
try {
getVacatureDetails(vacature);
} catch (IOException e) {
throw new RuntimeException(e);
eventService.logError(getClass().getName(), "scrapeVacatures", "error during scraping", e);
}
});
return vacatures.stream().filter(a -> !a.getLocatie().equals("Onbekende locatie")).collect(Collectors.toList());
return vacatures.stream().filter(a -> !a.getLocatie().equals("Onbekende locatie")).toList();
}
public void getVacatureDetails(Vacature vacature) throws IOException {