Skip to content

Instantly share code, notes, and snippets.

@wololock
Created October 26, 2014 07:43
Show Gist options
  • Save wololock/15f511fd9d7da9770f1d to your computer and use it in GitHub Desktop.
Save wololock/15f511fd9d7da9770f1d to your computer and use it in GitHub Desktop.
Extracting data from rows (Java, Jsoup)
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
public class ExtractingRowFromTableExample {
public static void main(String[] args) throws IOException {
String url = "http://www.cs.bilkent.edu.tr/~sekreter/SummerTraining/2014G/CS399.htm";
String username = "Samet";
Document document = Jsoup.connect(url).get();
Elements rows = document.select("tr:contains("+username+")");
for (Element row : rows) {
System.out.println("---------------");
System.out.printf("No: %s\n", row.select("td:eq(0)").text());
System.out.printf("Evaluator: %s\n", row.select("td:eq(4)").text());
System.out.printf("Status: %s\n", row.select("td:eq(5)").text());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment