Skip to content

Commit cbbceb5

Browse files
committed
Adapted AdMailScrapeService for new mail design
1 parent d28a257 commit cbbceb5

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
package dev.manuelschuler.kleinanzeigenadsrenewer.service;
22

33
import jakarta.mail.Message;
4+
import java.util.List;
45
import org.jsoup.nodes.Document;
56
import org.jsoup.nodes.Element;
67
import org.jsoup.select.Elements;
78

8-
import java.util.List;
9-
109
public class AdMailScrapeService extends ScrapeService {
1110

12-
private static final String RENEW_BUTTON_CLASS_NAME = ".cta-button-outline";
13-
private static final String AD_PAGE_URL = "s-anzeige";
11+
private static final String RENEW_BUTTON_QUERY = "a[title='Anzeige verlängern']";
12+
private static final String AD_PAGE_URL = "s-anzeige";
1413

15-
public AdMailScrapeService(Message mail) {
16-
super(mail);
17-
}
14+
public AdMailScrapeService(Message mail) {
15+
super(mail);
16+
}
1817

19-
public String getRenewLink() {
20-
Document document = this.getDocument();
21-
Elements renewButton = document.select(RENEW_BUTTON_CLASS_NAME);
22-
return renewButton.attr("href");
23-
}
18+
public String getRenewLink() {
19+
Document document = this.getDocument();
20+
Elements renewButton = document.select(RENEW_BUTTON_QUERY);
21+
return renewButton.attr("href");
22+
}
2423

25-
public String getAdName() {
26-
Document document = this.getDocument();
27-
List<Element> matchingElements = document.select("a").stream().filter(element -> element.attr("href").contains(AD_PAGE_URL)).toList();
28-
return matchingElements.getFirst().text();
29-
}
24+
public String getAdName() {
25+
Document document = this.getDocument();
26+
List<Element> matchingElements =
27+
document.select("a").stream()
28+
.filter(element -> element.attr("href").contains(AD_PAGE_URL))
29+
.toList();
30+
return matchingElements.getFirst().text();
31+
}
3032
}

0 commit comments

Comments
 (0)