I am trying to download the content of pages like this one and writing it into a .txt file for later use.
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
I keep getting this error, and if I use the ignoreContentType(true)
method it just gets rid of the error and my text file remains empty.
"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"