--- miscJava/SpejdernetScraper/src/dk/thoerup/spejdernetscraper/ScraperWorker.java 2013/08/15 13:50:50 2045 +++ miscJava/SpejdernetScraper/src/dk/thoerup/spejdernetscraper/ScraperWorker.java 2013/08/15 17:17:46 2046 @@ -50,12 +50,20 @@ String dataCsvUrl = "http://medlemssystem.spejdernet.dk/csvx.ashx?q=JQBOZXRtZXN0ZXIuS0ZVTS5NZW1iZXIsIE5ldG1lc3Rlci5LRlVNPgB4LlVuaXQuR3JvdXAuSWQgPT0gImd1aWQ6NWMwY2Y2MzgtZGM4Ny00MTNmLTkxYjYtOWM3MzAwYzcwMTM3Ig==&type=Member&view=csv"; //And this is the easieste way I've found to remain in session - Response data = Jsoup.connect(dataCsvUrl).cookies(cookies).timeout(10000).execute(); + Response data = Jsoup.connect(dataCsvUrl).cookies(cookies).timeout(10000).execute(); + if ( ! data.contentType().equalsIgnoreCase("text/x-csv; charset=iso-8859-1") ) { + rb.addString(start, "Data.csv - has the wrong content type: " + data.contentType()); + return; + } String dataCsv = data.body(); rb.addString(start, "Got data.csv"); String rollerCsvUrl = "http://medlemssystem.spejdernet.dk/DataExport.aspx?Id=5c0cf638-dc87-413f-91b6-9c7300c70137&listid=e8c5ae9d-5ea7-4a00-bea4-a0ce00ea891e&execute=true"; Response roller = Jsoup.connect(rollerCsvUrl).cookies(cookies).timeout(10000).execute(); + if ( ! roller.contentType().equalsIgnoreCase("text/x-csv; charset=iso-8859-1") ) { + rb.addString(start, "Roller.csv - has the wrong content type: " + roller.contentType()); + return; + } String rollerCsv = roller.body(); rb.addString(start, "Got roller.csv");