Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 49 additions & 23 deletions js/finanzennet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Updated 03.01.2025 by @dirkhe
// Updated 18.01.2025 by @dirkhe - Logging added

/** start date for historic rates when no min date is set on the input */
const DEFAULT_START_DATE = '2020-01-01';

var ArrayList = java.util.ArrayList;

var fetcher;
Expand Down Expand Up @@ -59,7 +62,11 @@ function prepare(
searchButton = page.getElementById("request-historic-price");

input = page.getElementById("fromDate");
input.setValue(input.getMin());
if (input.getMin()) {
input.setValue(input.getMin());
} else {
input.setValue(DEFAULT_START_DATE);
}

input = page.getElementById("toDate");
input.setValue(input.getMax());
Expand All @@ -68,39 +75,60 @@ function prepare(
Packages.de.willuhn.logging.Logger.debug("suche Link historische Kurse");
links = page.getAnchorByText("Historische Kurse");
page = links.click();
} catch (error) {
Packages.de.willuhn.logging.Logger.debug("suche Link Kurse & Realtime");
links = page.getAnchorByText("Kurse & Realtime");
page = links.click();
Packages.de.willuhn.logging.Logger.debug("suche Link historische Kurse");
links = page.getAnchorByText("Historische Kurse");
page = links.click();
} catch (error) {
try {
Packages.de.willuhn.logging.Logger.debug("suche Link Kurse & Realtime");
links = page.getAnchorByText("Kurse & Realtime");
page = links.click();
Packages.de.willuhn.logging.Logger.debug("suche Link historische Kurse");
links = page.getAnchorByText("Historische Kurse");
page = links.click();
} catch (error2) {
// navigate to historic rates for "Zertifikate"
Packages.de.willuhn.logging.Logger.debug("suche Link Historisch");
links = page.getAnchorByText("Historisch");
page = links.click();
}
}
try {
Packages.de.willuhn.logging.Logger.debug("suche Select strBoerse");
boerseSelect = page.getElementByName("strBoerse");
Packages.de.willuhn.logging.Logger.debug("suche search-Button");
searchButton = boerseSelect.getFirstByXPath("../../div/button");

input = page.getElementByName("dtDate1");
input.setValue(input.getMin());

input = page.getElementByName("dtDate2");
input.setValue(input.getMax());
} catch (error) {
// retrieve historic rates for "Zertifikate"
Packages.de.willuhn.logging.Logger.debug("suche Select historic-prices-stock-market");
boerseSelect = page.getElementById("historic-prices-stock-market");
Packages.de.willuhn.logging.Logger.debug("suche search-Button");
searchButton = page.getElementById("request-historic-price");

input = page.getElementById("derivative-historical-start-date");
input.setValue(DEFAULT_START_DATE);

input = page.getElementById("derivative-historical-end-date");
input.setValue(input.getMax());
}
Packages.de.willuhn.logging.Logger.debug("suche Select strBoerse");
boerseSelect = page.getElementByName("strBoerse");
Packages.de.willuhn.logging.Logger.debug("suche search-Button");
searchButton = boerseSelect.getFirstByXPath("../../div/button");

input = page.getElementByName("dtDate1");
input.setValue(input.getMin());

input = page.getElementByName("dtDate2");
input.setValue(input.getMax());
}

var liste = new ArrayList();
if (!page) {
Packages.de.willuhn.logging.Logger.error("Konnte Kurse Link nicht finden");
} else {
// Handelsplätze extrahieren

var cfg = new Packages.jsq.config.Config("Handelsplatz");
var listeHandelsplaetze = boerseSelect.getOptions(); // List of HtmlOption
for (var i = 0; i < listeHandelsplaetze.size(); i++) {
var platz = listeHandelsplaetze.get(i);
cfg.addAuswahl(platz.getText(), platz.getValueAttribute());
}
liste.add(cfg);
liste.add(cfg);
}


Expand Down Expand Up @@ -138,8 +166,6 @@ function process(config) {
} else {
list = Packages.jsq.tools.HtmlUnitTools.analyse(tab);
Packages.de.willuhn.logging.Logger.info(list.size() + " Kurse gefunden");


for (i = 0; i < list.size(); i++) {
try {
hashmap = list.get(i);
Expand Down Expand Up @@ -195,4 +221,4 @@ function search(fetch, search) {
page = wc.getPage(
"http://www.finanzen.net/suchergebnis.asp?frmAktiensucheTextfeld=" + search
);
}
}