Volley est une librairie fournie par Google afin de simplifier l’accès à des ressources réseau.
Pour l’utiliser, vous pouvez utiliser le jar en le téléchargeant ici et en le copiant dans le répertoire « libs » de votre projet
http://www.androidhive.info/2014/05/android-working-with-volley-library-1/
http://stackoverflow.com/questions/16659620/volley-android-networking-library
http://www.technotalkative.com/android-volley-library-example/
http://karanbalkar.com/2014/05/tutorial-81-using-volley-networking-library-in-android/
CREATION D’UNE REQUETE :
Source ici de test de requête JSON
PARSING JSON :
http://www.androidhive.info/2014/09/android-json-parsing-using-volley/
JSOUP :
Test de la présence de la page :
try {
document = Jsoup.connect("http://www.malformedurl.com").get();
// ...
} catch (UnknownHostException e) {
System.err.println("Unknown host");
e.printStackTrace(); // I'd rather (re)throw it though.
}
a) Installation dans le projet :
Téléchargez le jar ici
Placez le dans le dossier libs.
Incluez le : click droit puis
b) Codage Jsoup :
Reformatez le code html : http://www.freeformatter.com/html-formatter.html
Tester les commandes sur une page html : http://try.jsoup.org/
http://jsoup.org/cookbook/extracting-data/selector-syntax
CSS Query :h2 ou p:eq(2) ou .nom_de_classe
private Document htmlDocument;
htmlDocument = Jsoup.connect(htmlPageUrl).get();
Elements uu = htmlDocument.select("ul.tabsContent.dontSwitch.block-white > li");
String sTitre=uu.get(0).select("h2").text()
String sGlobal=uu.get(0).select("p:eq(2)").text();
exemple de code :
……….
Références :
Exemple pour le titre du document
htmlContentInStringFormat = htmlDocument.title();
Références :
http://inducesmile.com/android/android-html-parser-using-jsoup-tutorial/
http://o7planning.org/web/fe/default/en/document/864702/jsoup-java-html-parser-tutorial#a864736
http://stackoverflow.com/questions/21336845/how-to-parse-ul-li-tags-using-jsoup-in-android
http://stackoverflow.com/questions/14568401/jsoup-getting-class-element-with-whitespace-in-name
Votre commentaire