A real-time scraper for monitoring disaster updates from the Ipswich City Council Disaster Dashboard.
Disaster Watch is a Node.js application that automatically scrapes and monitors disaster updates from the Ipswich City Council Disaster Dashboard. It uses Puppeteer for browser automation to retrieve live updates about natural disasters, emergency alerts, and other critical information.
IMPORTANT: This software is created for EDUCATIONAL PURPOSES ONLY.
This project is not affiliated with, endorsed by, or in any way officially connected to the Ipswich City Council or any governmental agency. It is an independent project designed to demonstrate web scraping techniques and provide a learning resource for developers.
- This software should only be used for personal, educational purposes.
- Users are responsible for ensuring their use of this software complies with all applicable laws and regulations.
- Be aware that web scraping may violate a website's terms of service. Always review a website's policies before scraping.
- Do not use this software in a way that could overload or damage the target website's servers.
- This software does not collect or store personal data.
- All data obtained is publicly available on the Ipswich City Council Disaster Dashboard.
- No warranty is provided regarding the accuracy or reliability of the extracted information.
- Real-time Monitoring: Fetches disaster updates every 60 seconds
- Robust Scraping: Uses Puppeteer to render JavaScript and access dynamically loaded content
- Fault Tolerance: Multiple fallback mechanisms to ensure continuous operation
- Detailed Logging: Comprehensive logging to help troubleshoot any issues
- Node.js 14.x or higher
- npm or yarn package manager
- Chromium (automatically installed with Puppeteer)
-
Clone this repository:
git clone <your-repo-url> cd disaster-watch
-
Install dependencies:
npm install # or yarn install # or bun install
-
Build the project:
npm run build # or yarn build # or bun run build
Start the application:
npm start
# or
yarn start
# or
bun startThe application will:
- Start a headless Chrome browser
- Navigate to the disaster dashboard
- Extract update information
- Log the data to the console
- Repeat every 60 seconds
All configuration options are centralized in the src/config.ts file. You can modify these settings to customize the behavior of the application:
export const config = {
// URL to scrape for disaster updates
scrapeUrl: 'https://disaster.ipswich.qld.gov.au/',
// Time between update checks in milliseconds (default: 60000ms = 1 minute)
intervalMs: 60000,
// Number of consecutive failures before trying alternative approach
maxFailuresBeforeAlternative: 2,
// Number of consecutive failures before using fallback data
maxConsecutiveFailures: 5,
// ...other settings
}You can customize how often summaries are displayed and enable/disable compact logging:
notifications: {
// How often to show a summary when no updates have changed (in hours)
summaryInterval: 1,
// Whether to use compact logging (dots) for repeated checks with no changes
useCompactLogging: true
}You can also use environment variables to configure some options without modifying the code:
- Copy
.env.exampleto.envin the project root - Edit the values in your
.envfile - Restart the application
Example .env file:
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-url
This application can send disaster update notifications to a Discord channel using webhooks. To set this up:
- In your Discord server, go to Server Settings β Integrations β Webhooks
- Click New Webhook, give it a name (e.g., "Disaster Watch"), and select the channel where you want notifications
- Copy the webhook URL
- Create a
.envfile in the project root (copy from.env.example) and add your webhook URL:DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-url
Alternatively, you can directly edit the webhook URL in the config.ts file:
discord: {
url: process.env.DISCORD_WEBHOOK_URL || 'your-webhook-url-here',
username: 'Disaster Watch',
avatarUrl: 'https://i.imgur.com/GQgpIAX.png'
}You can customize how the webhook appears in Discord:
- Username: Change the name that shows for the webhook messages
- Avatar: Set a custom avatar by updating the
avatarUrlproperty
Disaster updates are automatically color-coded in Discord based on keywords in the title:
- π΄ Red: Emergencies, warnings, alerts, evacuation notices, danger
- π‘ Yellow: Watches, advisories, preparation notices
- π’ Green: Recovery information, all-clear notices, safety confirmations
- βͺ Gray: General updates with no specific severity indication
To disable Discord notifications, leave the webhook URL empty.
The application uses different types of console output:
- Regular updates: When new content is found, full details are displayed
- Compact logging: For unchanged content, a simple dot (
.) is printed to reduce console clutter - Summary messages: Displayed hourly to confirm the application is still running
- Warning messages: When fallback data is being used
If the website structure changes, you may need to update the selectors in scraper.ts. The key parts to look for:
// Find content items
const contentItems = $('.contentItem');
// Extract title
const title = $(el).find('.contentTitle a').text().trim();
// Extract timestamp
const timestamp = $(el).find('.updateInfo').text().trim();
// Extract content
const contentElement = $(el).find('.contentDetail');The fallback data used when scraping fails can be modified in index.ts:
const fallbackData: Update[] = [
{
title: "[FALLBACK DATA] Your custom title here",
timestamp: "Last Updated time [FALLBACK DATA]",
content: "[FALLBACK DATA] Your custom content here",
isFallbackData: true
},
// Add more fallback items as needed
];This application uses:
- TypeScript: For type-safe code
- Puppeteer: For browser automation and rendering JavaScript-loaded content
- Cheerio: For HTML parsing
- Axios: For alternative HTTP requests when needed
The scraper tries multiple approaches to ensure reliable data:
- Puppeteer-powered main scraping with full JavaScript rendering
- Alternative API approach as backup
- Hardcoded fallback data as a last resort after multiple failures
The system implements a progressive failure handling strategy:
- Retries with the main scraper first
- Attempts alternative scraping methods
- Falls back to saved data after multiple failures
- Provides detailed logging for debugging
For development, you can run the application with:
npm run dev
# or
yarn dev
# or
bun run devCommon issues and solutions:
- No data returned: The site structure may have changed. Check the console logs for HTML structure analysis.
- Browser launch fails: Ensure you have sufficient permissions and no firewalls blocking Chrome.
- Memory usage concerns: The application automatically closes the browser after each scraping session.
- Discord webhook not working: Verify your webhook URL is correct and has the proper permissions.
- Repetitive logging: Adjust the
notifications.useCompactLoggingandnotifications.summaryIntervalsettings.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project was created as an educational demonstration of web scraping techniques.
- Thanks to the open-source community for the various libraries used in this project.