//code
import org.jsoup.*;
import org.jsoup.nodes.*;
import org.jsoup.select.*;
import org.jsoup.safety.*;
import org.jsoup.helper.*;
import org.jsoup.nodes.*;
import org.jsoup.parser.*;
import org.jsoup.select.*;
/**
*A demonstration of how to get the value of a div, with the intention of adding
* to an existing project.
*/
public class GetValueOfDiv {
public static void main(String[] args) throws Exception {
//Load HTML from URL
URL htmlFile = new URL("");
//Open a document with the source code
Document document = Jsoup.connect(htmlFile).get();
//Get the value of the div
Element div = document.select("div#product_name").first();
//print the value
System.out.println("The value of div #product_name is: " + div.text());
}
}
Result:
The value of div #product_name is: BTC+
There's a bug with Kaggle site, after logging in you have to refresh the page for the site to work.
A:
This is one of the few instances where using a regex might be advantageous over using a simple select method.
Here is what you could use (compare to what you currently have in your code):
import org.jsoup.nodes.*;
import org.jsoup.nodes.Element.*;
import org.jsoup.select.*;
public class GetValueOfDiv {
public static void main(String[] args) throws Exception {
//Load HTML from URL
URL htmlFile = new URL("");
//Open a document with the source code
Document document = Jsoup. ac619d1d87
Related links:
Comments