Skip to content

Tag: jsoup

Filtering out formatting tags from JSoup selectors

JSoup here. I have the following HTML I’m trying to parse: Unfortunately its actually slightly malformed (missing some closing tags, opening and closing tags on <b> and <u> are out of order, etc.) but I’m hoping JSoup can handle that. I don’t have control over the HTML. I have the following Java model/POJO: I am trying to get JSoup to

Jsoup – Remove all children from an element

I have an element as below. When I apply .empty() method on the element it is removing the text “Name”. Is there any other way to remove all child elements blindly from an element except its text ? I know the below example don’t have any child elements. Answer Try this. output:

Scrape currency exchange data from

I need get the currency data from website, here the website HTML table code: I wrote these code but I could not handle the code: But I got this problem: Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException: Cannot invoke “org.jsoup.nodes.Element.attr(String)” because “link” is null How can I handle this problem, how can I get currency rate. Answer You can try like this:

Basic JSoup form Submission

My form submission does not seem to work, I tried JAunt it was able to submit so when using JSoup I don’t understand why it returns 404. Connection.Response response = Jsoup.connect(“https://…