mirror of
https://github.com/mblanke/Gov_Travel_App.git
synced 2026-03-01 14:10:22 -05:00
Add Python web scraper for NJC travel rates with currency extraction
- Implemented Python scraper using BeautifulSoup and pandas to automatically collect travel rates from official NJC website - Added currency extraction from table titles (supports EUR, USD, AUD, CAD, ARS, etc.) - Added country extraction from table titles for international rates - Flatten pandas MultiIndex columns for cleaner data structure - Default to CAD for domestic Canadian sources (accommodations and domestic tables) - Created SQLite database schema (raw_tables, rate_entries, exchange_rates, accommodations) - Successfully scraped 92 tables with 17,205 rate entries covering 25 international cities - Added migration script to convert scraped data to Node.js database format - Updated .gitignore for Python files (.venv/, __pycache__, *.pyc, *.sqlite3) - Fixed city validation and currency conversion in main app - Added comprehensive debug and verification scripts This replaces manual JSON maintenance with automated data collection from official government source.
This commit is contained in:
46
extract_cities.js
Normal file
46
extract_cities.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const fs = require("fs");
|
||||
|
||||
// Read accommodation rates
|
||||
const accomData = JSON.parse(
|
||||
fs.readFileSync("./data/accommodationRates.json", "utf8")
|
||||
);
|
||||
const cities = Object.keys(accomData.cities);
|
||||
|
||||
// Separate Canadian and international
|
||||
const canadian = cities.filter((c) => accomData.cities[c].region === "Canada");
|
||||
const international = cities.filter(
|
||||
(c) => accomData.cities[c].region !== "Canada"
|
||||
);
|
||||
|
||||
console.log("=== ACCOMMODATION CITIES ===");
|
||||
console.log(`Total: ${cities.length}`);
|
||||
console.log(`Canadian: ${canadian.length}`);
|
||||
console.log(`International: ${international.length}\n`);
|
||||
|
||||
console.log("=== INTERNATIONAL CITIES (for airport codes) ===");
|
||||
international.forEach((key) => {
|
||||
const city = accomData.cities[key];
|
||||
console.log(`${key}: ${city.name} (${city.country})`);
|
||||
});
|
||||
|
||||
// Now get existing airport codes from flightService.js
|
||||
const flightService = fs.readFileSync("./flightService.js", "utf8");
|
||||
const airportCodeMatch = flightService.match(
|
||||
/const airportCodes = \{([^}]+)\}/s
|
||||
);
|
||||
|
||||
console.log("\n=== MISSING AIRPORT CODES ===");
|
||||
const missing = [];
|
||||
international.forEach((key) => {
|
||||
const normalized = key.toLowerCase();
|
||||
if (
|
||||
!flightService.includes(`${normalized}:`) &&
|
||||
!flightService.includes(`"${normalized}":`)
|
||||
) {
|
||||
const city = accomData.cities[key];
|
||||
missing.push(`${normalized} => ${city.name} (${city.country})`);
|
||||
}
|
||||
});
|
||||
|
||||
missing.forEach((m) => console.log(m));
|
||||
console.log(`\nTotal missing: ${missing.length}/${international.length}`);
|
||||
Reference in New Issue
Block a user