@@ -222,30 +222,57 @@ protected void loadAdditionalSources(Element cityEl)
222222 /**
223223 * Fetch all sources (primary + additional) and return combined content
224224 */
225+ protected static final String RAW_DIR = "source/city/analysis/raw/" ;
226+
225227 public String fetchAllSources ()
226228 {
227229 StringBuilder all = new StringBuilder ();
230+ String dateTime = java .time .LocalDateTime .now ().format (java .time .format .DateTimeFormatter .ofPattern ("yyyy-MM-dd/HH-mm-ss" ));
231+ java .nio .file .Path rawSessionDir = java .nio .file .Paths .get (RAW_DIR + dateTime );
232+ try { java .nio .file .Files .createDirectories (rawSessionDir ); } catch (Exception e ) { /* ignore */ }
228233
229234 String deeds = fetchDeedsSearch ();
230- if (deeds != null ) all .append (deeds );
235+ if (deeds != null ) { all .append (deeds ); saveRaw ( rawSessionDir , "deeds" , deeds ); }
231236
232237 String property = fetchPropertyRecords ();
233- if (property != null ) all .append (property );
238+ if (property != null ) { all .append (property ); saveRaw ( rawSessionDir , "property-records" , property ); }
234239
235240 String rod = fetchRegisterOfDeeds ();
236- if (rod != null ) all .append (rod );
241+ if (rod != null ) { all .append (rod ); saveRaw ( rawSessionDir , "register-of-deeds" , rod ); }
237242
243+ int i = 0 ;
238244 for (String sourceUrl : additionalSources )
239245 {
240246 System .out .println ("-- : [CityAnalysisServer] Fetching additional source: " + sourceUrl );
241247 String content = httpGet (sourceUrl );
242- if (content != null ) all .append (content );
248+ if (content != null )
249+ {
250+ all .append (content );
251+ saveRaw (rawSessionDir , "source-" + i , content );
252+ }
253+ i ++;
243254 }
244255
245- System .out .println ("-- : [CityAnalysisServer] All sources fetched. Total chars: " + all .length ());
256+ System .out .println ("-- : [CityAnalysisServer] All sources fetched. Total chars: " + all .length () + " Raw saved to: " + rawSessionDir );
246257 return all .toString ();
247258 }
248259
260+ /**
261+ * Save raw web result to /raw/<datetime>/ directory
262+ */
263+ protected void saveRaw (java .nio .file .Path dir , String label , String content )
264+ {
265+ try
266+ {
267+ java .nio .file .Path file = dir .resolve (cityName + "." + label + ".html" );
268+ java .nio .file .Files .writeString (file , content );
269+ }
270+ catch (Exception e )
271+ {
272+ System .err .println ("-- : [CityAnalysisServer] Raw save error: " + e .getMessage ());
273+ }
274+ }
275+
249276 /**
250277 * HTTP/HTTPS GET with retry logic and SSL cert storage.
251278 * Port-aware: supports 21, 22, 80, 443, 8080 outbound.
0 commit comments