Skip to main content
added 370 characters in body
Source Link
Kurtis Nusbaum
  • 30.9k
  • 13
  • 81
  • 105

JSoup is pretty nice and getting popular. Here's how you could just parse the whole table:

URL url = new URL("http://www.nseindia.com/content/equities/niftysparks.htm"); Document doc = Jsoup.parse(url, 3000); Element table = doc.select("table[title=Avgångar:]").first(); Iterator<Element> iteit = table.select("td").iterator(); //we know the third td element is where we wanna start so we call .next twice it.next(); it.next(); while(it.hasNext()){ // godo throughwhat eachever you want with the td element inhere  //iterate three times to get to the next td you want. checking after the first // one to make sure // we're not at the end of the table. it.next(); if(!it.hasNext()){ break; } it.next(); it.next(); } 

JSoup is pretty nice and getting popular. Here's how you could just parse the whole table:

URL url = new URL("http://www.nseindia.com/content/equities/niftysparks.htm"); Document doc = Jsoup.parse(url, 3000); Element table = doc.select("table[title=Avgångar:]").first(); Iterator<Element> ite = table.select("td").iterator(); while(it.hasNext()){ // go through each td element in the table } 

JSoup is pretty nice and getting popular. Here's how you could just parse the whole table:

URL url = new URL("http://www.nseindia.com/content/equities/niftysparks.htm"); Document doc = Jsoup.parse(url, 3000); Element table = doc.select("table[title=Avgångar:]").first(); Iterator<Element> it = table.select("td").iterator(); //we know the third td element is where we wanna start so we call .next twice it.next(); it.next(); while(it.hasNext()){ // do what ever you want with the td element here  //iterate three times to get to the next td you want. checking after the first // one to make sure // we're not at the end of the table. it.next(); if(!it.hasNext()){ break; } it.next(); it.next(); } 
Source Link
Kurtis Nusbaum
  • 30.9k
  • 13
  • 81
  • 105

JSoup is pretty nice and getting popular. Here's how you could just parse the whole table:

URL url = new URL("http://www.nseindia.com/content/equities/niftysparks.htm"); Document doc = Jsoup.parse(url, 3000); Element table = doc.select("table[title=Avgångar:]").first(); Iterator<Element> ite = table.select("td").iterator(); while(it.hasNext()){ // go through each td element in the table }