Skip to content

Kavyasrigotte/Weather-API

 
 

Repository files navigation

🌦️ Weather API - Your Personal Weather Scraper!

A simple yet powerful weather scraper built with Node.js, Express, and Cheerio. This project dynamically fetches real-time weather data for any city, scrapes the necessary details, and presents them on an intuitive user interface. 🌍☀️🌧️


✨ Features That Shine

🔹 Real-Time Weather Data: Get instant updates on:

  • 📅 Date
  • 🌡️ Temperature (Current, Min & Max)
  • 💧 Humidity
  • 🔽 Pressure

🔹 Express-Powered API: A lightweight and efficient API built with Express.js.

🔹 Web Scraping Magic: Uses Axios to fetch and Cheerio to extract weather details effortlessly.

🔹 Beautiful & Responsive UI: Clean, minimal, and user-friendly interface for seamless interaction.


🔧 Prerequisites

Before you get started, ensure you have:

Node.js (v12 or later recommended) ✅ npm (Comes bundled with Node.js)


🚀 Quick Installation

1️⃣ Clone the repository:

git clone https://github.com/GauravKarakoti/weather-api.git
cd weather-api

2️⃣ Install dependencies:

npm install

3️⃣ Set up environment variables:

cp .env.example .env

(Update .env with required API endpoint, CSS selectors, and server port.)


🌐 Live Demo & Usage

🎯 Try It Online!

🚀 Live Frontend Demo – Just enter a city name and get weather details instantly!

🖥️ Running Locally

1️⃣ Start the server:

node server.js

(Server runs on the port specified in .env, default: 3003)

2️⃣ Launch the Frontend:

  • Open index.html in a browser.
  • Or use Live Server for better performance.

3️⃣ Get Weather Updates:

  • Enter a city name 📍
  • Click Get Weather ☁️
  • See real-time weather info! 🌡️

🔗 Backend API (Deployed)

🌍 Weather API Backend – Fetch weather details via endpoints.

Example: Delhi Weather


📂 Project Structure

weather-api/
│-- frontend/
│   ├── index.html      # User Interface
│   ├── styles.css      # Styling
│   ├── script.js       # API Handling
│
│-- server/
│   ├── server.js       # Express Backend
│   ├── scraper.js      # Web Scraping Logic
│   ├── .env            # Configurations
│   ├── package.json    # Dependencies
│
└── README.md           # Documentation

🔧 Tech Stack & Dependencies

🛠️ Built With:

  • Express.js – Fast & lightweight web framework 🚀
  • Axios – Fetching HTML content effortlessly 🌐
  • Cheerio – Scraping and parsing made easy 🧐
  • CORS – Secure cross-origin requests 🔄
  • dotenv – Manages environment variables 🔐
  • Jest - Efficient And RObut management for testing 💪🏻

🤝 Contributions Welcome!

💡 Have suggestions or improvements? Open an issue or submit a pull request!

🔄 Local Development Notes

🔹 When testing locally, switch the API endpoint in index.html:

const apiUrl = `http://localhost:3003/${city}`;

🔹 Before submitting a pull request, revert it to the deployed API.


🚀 Stay Ahead of the Weather – One City at a Time! 🌍☀️🌧️

🔝 Back to Top

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 78.7%
  • CSS 13.7%
  • HTML 7.3%
  • Dockerfile 0.3%