java - Get data from table using jSoup -
I'm looking at using jSoup to get data from the table. I want to put it in the table, which I can use in my code.
I am also not sure how to do this I am playing with JSOP and currently I am able to print each cell using a loop from the table - but obviously, it Can not always be used because the number of cells in the table will change.
Document Doctor = Jsoup.connect ("http://www.sportinglife.com/greyhounds/abc-guide") .get (); Int n = 0; Whereas (n & lt; 100) {element tablehead = doc.select ("td"). Get (n); (Element element: tableHeader.children ()) {// Here you can do something with each element System.out.println (element.text ()); } N ++; }
How can I do this?
To achieve your goal, you must apply a few things. Take a look at this Groove script - Now let us know what we have
list & lt; Element & gt; Here we are specifying that we need to enter the line tr / Code> This is the instant child of the tomb
which is immediately table
with ID ABC guide
. In return you get a list of elements
objects that describe those tr
rows. Maps & lt; String, string & gt; Data = new hashmap & lt; & Gt; ()
We will store our results in a simple hash map for further evaluation eg. Put those scrap data into the database.
line ) {string dog = row. Selection ('TD: eq (0)'). Text () string race = line .select ('td: eq (1)'). Text () data.put (dog, race)}
Now we repeat on each Element
and we will insert the contents from the first cell Choose the form: string dog = line.sact ('td: eq (0)'). Text ()
And we repeat this step to retrieve the content in the form of a text from the second cell: string race = line .select ('td: eq (1)'). Text ()
. So we just put those data in the hash map.
Edit:
Java code sample -
I hope this example will help in developing your application with the information provided. will help you.
/ div>
Comments
Post a Comment