herunterladen Ich versuche, den Inhalt von Seiten wie this one herunterzuladen und es in eine TXT-Datei für die spätere Verwendung zu schreiben.Versuchen, URL contentt in TXT-Datei mit jsoup
doc = Jsoup.connect(link).userAgent("Mozilla").get();
String cityInfo = doc.html();
int index = cityInfo.indexOf("},"); // keeps just the first object as it has the highest score.
String cityInfo1 = cityInfo.substring(index+1) + "}]}"; // gets the object in the correct format as some characters are not selected when downloading
bw1.write(cityInfo1); //saves json object into text file
Ich erhalte diesen Fehler, und wenn ich die ignoreContentType(true)
Methode verwenden, es wird nur loswerden Fehler und meine Textdatei bleibt leer.
"Exception in thread "main"
org.jsoup.UnsupportedMimeTypeException: Unhandled content type.
Must be text/*, application/xml, or application/xhtml+xml.
Mimetype=application/json, URL=http://transport.opendata.ch/v1/locations?query=Aarau"
Warum Jsoup für Json formatierte Daten verwenden? – Tim
Ich möchte die ganze Seite nur als Text herunterladen und später behandeln. Was würdest du vorschlagen? – BlueWookie
Überprüfen Sie das JSON-Format: https://en.wikipedia.org/wiki/JSON – Tim