Skip to content

Tag: jsoup

How to change color of a cell in HTML table using JSoup?

I need to parse a table using Java and Jsoup and change the color of the cell based on it’s value. This is what the html table looks like and it is how the color of the cell needs to be defined I wrote a script that can ready the value of a cell and change the text from it,

Jsoup HtmlToPlainText function adding extra new line

If the text is already plain text and passed to the function new HtmlToPlainText().getPlainText() then the new line character is getting added to the result text. It looks like Jsoup is doing some formatting and adding a line break. I tried outputSettings.prettyPrint(false); but it is not helping. Input text can be HTML or plain text. I want the text to

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 not able to get links from html

I’m trying to get links from html of a site but unable to do so using Jsoup. This is the HTML: This is the android code that I wrote which doesn’t seem to work: Can someone please help me with this? Thanks Edit: Basically I’m trying to get those 6 links and add them to my list to use it

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:

Add https to missing strings of an array?

I’m writing an app for a client who doesn’t have an official API but wants the app to extract video links from his website so I wrote a logic using jsoup. Everything seems to work fine except some of the links don’t start with https so I’m trying to add it before the URL. Here’s my code: The website contains

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: