-1

I've been using Jsoup for a long time. I need to get values of a table.

That's the link i'm work on : https://www.kayseri.bel.tr/vefat-ilanlari

The problem here: I can't directly access the values I want.

As you can see at below i need to access table values with item.Adsoyad function.

values i want

When i check values with opera developer tools like below i realized i can access values somehow. Now my question is how do I do this.

values i reached

I only came until this part which returns the code you see in Log.


try { Document document = Jsoup.connect("https://www.kayseri.bel.tr/vefat-ilanlari").timeout(10000).get();

if (document != null) { Elements adiSoyadi = document.select("tbody td[data-th = Adı Soyadı]"); Log.e("loge", "run: " + adiSoyadi.text()); } } catch (IOException e) { e.printStackTrace(); }

Returning value :

E/loge: run: {{item.AdSoyad}}

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
UmutTekin
  • 216
  • 2
  • 15
  • please can you check this answer and question? https://stackoverflow.com/questions/24772828/how-to-parse-html-table-using-jsoup – Hatice May 02 '19 at 13:08
  • i dont think its answer of my question. I know how to parse table or the other things. But my real question is how to acces value of item.adsoyad. I cant extract names from item.adsoyad method – UmutTekin May 02 '19 at 13:13
  • 1
    The data in the table is fetched from `https://www.kayseri.bel.tr/api/VefatEdenler/Getir?Tarih=02.05.2019`. You should download that file (which is json) and then retreive the data you want. – TDG May 02 '19 at 16:15
  • I don't know how did you access this link but thank you so much. You helped me a lot. – UmutTekin May 02 '19 at 17:06

1 Answers1

0

So if I understand correctly you are succeeding in finding all the table fields that have the attribute data-th set to Adı Soyadı as Elements, but you just need to get their text values. You can do that like this (with Java 8 or higher):

List<String> values = adiSoyadi.stream() // streaming all the elements 
.map(e -> e.text()) // getting the text from each element
.collect(Collectors.toList()) // collecting the Strings in a list
SylarBenes
  • 411
  • 3
  • 7
  • still returns same value. " E/loge: run: {{item.AdSoyad}} " And you got me wrong. I dont need text value of the element. It's easy. I need to get item.Adsoyad's value. You can check the site. You'll see table values doesnt show on html. I need to access that values with function of item.Adsoyad – UmutTekin May 02 '19 at 13:47
  • 1
    Oh ok. So your issue is that you are trying to Jsoup elements that are generated by Javascript? In that case I refer you to this one: [https://stackoverflow.com/questions/7488872/page-content-is-loaded-with-javascript-and-jsoup-doesnt-see-it] – SylarBenes May 02 '19 at 13:57
  • I think thats my problem. So i cant use jSoup. Thanks for your help – UmutTekin May 02 '19 at 14:08