|
1 | 1 | package dev.manuelschuler.kleinanzeigenadsrenewer.service;
|
2 | 2 |
|
3 | 3 | import jakarta.mail.Message;
|
| 4 | +import java.util.List; |
4 | 5 | import org.jsoup.nodes.Document;
|
5 | 6 | import org.jsoup.nodes.Element;
|
6 | 7 | import org.jsoup.select.Elements;
|
7 | 8 |
|
8 |
| -import java.util.List; |
9 |
| - |
10 | 9 | public class AdMailScrapeService extends ScrapeService {
|
11 | 10 |
|
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"; |
14 | 13 |
|
15 |
| - public AdMailScrapeService(Message mail) { |
16 |
| - super(mail); |
17 |
| - } |
| 14 | + public AdMailScrapeService(Message mail) { |
| 15 | + super(mail); |
| 16 | + } |
18 | 17 |
|
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 | + } |
24 | 23 |
|
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 | + } |
30 | 32 | }
|
0 commit comments