Created
November 17, 2017 19:35
-
-
Save wuerges/4d126de6c51b4f066c3d942c97fd71af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ew.spellbook.myapplication; | |
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
import org.jsoup.select.Elements; | |
import java.io.IOException; | |
/** | |
* Created by ew on 17/11/17. | |
*/ | |
public class TableFetch { | |
public static void takeTable() { | |
Thread t = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
Document doc = null; | |
try{ | |
doc = Jsoup.connect("http://www.uffs.edu.br/campi/chapeco/restaurante_universitario").get(); | |
// Localiza a primeira tabela | |
for (Element table : doc.select("table")) { | |
// Localiza cada uma das linhas | |
for (Element row : table.select("tr:gt(0)")) { | |
// Localiza cada uma das celulas de cada linha | |
Elements tds = row.select("td"); | |
for(Element line : tds) { | |
// Pega o texto contendo o ingrediente de dentro da celula | |
String s = line.text(); | |
System.out.println(s); | |
} | |
} | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
t.start(); | |
try { | |
t.join(); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment