diff options
author | Andreas Abraham <andreas.abraham@egiz.gv.at> | 2019-07-31 13:24:36 +0200 |
---|---|---|
committer | Andreas Abraham <andreas.abraham@egiz.gv.at> | 2019-07-31 13:24:36 +0200 |
commit | 0f031d36c2e6292b2ba77ca6903659ac0e9fc378 (patch) | |
tree | 3d3d6c4a9c0e539be77ba29a4ff81b02aeb39b89 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java | |
parent | 90c6d9ce3156026664feb807b9231205676e3ad6 (diff) | |
download | pdf-over-0f031d36c2e6292b2ba77ca6903659ac0e9fc378.tar.gz pdf-over-0f031d36c2e6292b2ba77ca6903659ac0e9fc378.tar.bz2 pdf-over-0f031d36c2e6292b2ba77ca6903659ac0e9fc378.zip |
pdf-over uses now jsoup to read dynamic values from html content
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java index 410ba3c1..04397f14 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java @@ -24,6 +24,11 @@ import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpState; import org.apache.commons.httpclient.protocol.Protocol; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.nodes.Node; +import org.jsoup.select.Elements; +import org.jsoup.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -148,6 +153,23 @@ public class MobileBKUHelper { } return found.substring(startidx + 1, endidx); } + + /** + * This method is the same as the non optional method but instead of throwing the exception it returns null + * @return the string or null + */ + public static String extractValueFromTagWithParamOptional(String data, String tag, + String param, String value, String returnparam) { + String str; + try { + str = extractValueFromTagWithParam(data, tag, param, value, returnparam); + } catch (Exception e) { + log.debug("Optional value is not available"); + str = null; + } + return str; + + } /** * Extracts the content from an XML tag from data with the given param="value" @@ -291,4 +313,21 @@ public class MobileBKUHelper { } return client; } + + /*** + * + * @param htmlString describes the html data in String representation + * @param attributeName is the attribute which should be selected + * @return returns the attribute name or null otherswise + */ + public static String getNameAttribute(String htmlString, String attributeName) { + + Document doc = Jsoup.parse(htmlString); + Elements inputs = doc.select("div input#" + attributeName); + + if (inputs.size() == 0 ) return null; + + String name = inputs.get(0).attr("name"); + return name; + } } |