A grabber for weather.com data with various output formats.
Project description
Weather Forecast CLI Script
Overview
This script fetches and parses weather forecast data from Weather.com and formats it for display in various environments such as a terminal or Waybar, a status bar tool. It leverages pyquery for HTML parsing and provides detailed weather information, including hourly and daily predictions, formatted for ease of use.
Waybar widget
Terminal Console
Features
- Retrieves current weather and forecasts for a specified location.
- Displays weather data in different formats:
- Console output: Richly formatted weather data with icons.
- Waybar JSON: For integration with Waybar.
- Supports multiple languages for Weather.com data.
- Includes data such as:
- Current temperature and "feels-like" temperature.
- Wind speed, humidity, visibility, and air quality.
- Hourly and daily forecasts with icons and precipitation chances.
Requirements
Requires Python 3 or newer.
Install the package and all dependencies with:
pip install .
Or, for development (editable install with dev dependencies):
pip install -e .[dev]
Output Formats
Console Output
The script displays a formatted weather summary, including:
- Current weather status.
- Temperature (current, max/min).
- Wind, humidity, visibility, and air quality.
- Hourly and daily forecasts with icons.
Waybar JSON
The JSON includes:
text: Current weather icon and temperature.alt: Weather status.tooltip: Detailed weather information.class: Status code for further customization.
JSON General output
Here the following JSON Schema for this output.
The key values for this json is:
temperature: An object containing the temperature information with the following fields:current: The current temperature.feel: The temperature feelmax: The maximum temperaturemin: The minimum temperature
There's also other fields like hourly_predictions and daily_predictions containing lists of predictions informations. More defaults on JSON Schema.
Integration with Waybar
To integrate the script with Waybar:
-
Add a custom script module in Waybar's configuration:
{ "modules-left": ["custom/weather"], "custom/weather": { "exec": "weathergrabber --output waybar", "interval": 600 } }
-
Reload Waybar to apply the changes.
Error Handling
- Validates
weather_idandlanginputs. - Handles HTTP errors gracefully, including 404 errors for invalid locations.
CI & Test Coverage
The test suite is run automatically on every push and pull request using GitHub Actions. Coverage results are uploaded to Codecov and displayed above.
To run tests and check coverage locally:
pytest --cov=weathergrabber --cov-report=term
License
This script is open-source and available under the MIT License.
CLI Usage
You can run the CLI as an installed command:
weathergrabber [location_name] [options]
Or as a Python module:
python -m weathergrabber [location_name] [options]
Importing as a Python module
You can also use the main API or CLI entry point in your own Python code:
import weathergrabber
# Call the main API
weathergrabber.main(log_level="INFO", location_name="London", location_id="", lang="en-GB", output="console", keep_open=False, icons="emoji")
# Or run the CLI programmatically
weathergrabber.main_cli()
Arguments
location_name(positional, optional): City name, zip code, etc. If not provided, you can use--location-idor theWEATHER_LOCATION_IDenvironment variable.
Options
--location-id,-l: 64-character-hex code for location (from Weather.com)--lang,-L: Language (e.g.,pt-BR,fr-FR). Defaults to system locale if not set.--output,-o: Output format. One ofconsole,json, orwaybar. Default:console.--keep-open,-k: Keep open and refresh every 5 minutes (only makes sense forconsoleoutput).--icons,-i: Icon set.fafor Font-Awesome,emojifor emoji icons. Default:emoji.--log: Set logging level. One ofdebug,info,warning,error,critical. Default:critical.
Environment Variables
LANG: Used as default language if--langis not set.WEATHER_LOCATION_ID: Used as default location if neitherlocation_namenor--location-idis set.
Example Usage
weathergrabber "London" --output console --lang en-GB
weathergrabber --location-id 1234567890abcdef... --output json
weathergrabber "Paris" -o waybar -i fa
Or as a Python module:
python -m weathergrabber "London" --output console --lang en-GB
python -m weathergrabber --location-id 1234567890abcdef... --output json
python -m weathergrabber "Paris" -o waybar -i fa
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weathergrabber-0.0.8a4.tar.gz.
File metadata
- Download URL: weathergrabber-0.0.8a4.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
395a3d090606bb33c46107de1ff60fe3fd6cb494f2850bcd2dfc1b8dabd46442
|
|
| MD5 |
c90b92bdb586103a30ca562288a90614
|
|
| BLAKE2b-256 |
eeca3b4748148259c6d2313005807fbd9528cd95a378644931717038630b16d1
|
Provenance
The following attestation bundles were made for weathergrabber-0.0.8a4.tar.gz:
Publisher:
publish-to-pypi.yml on cjuniorfox/weathergrabber
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weathergrabber-0.0.8a4.tar.gz -
Subject digest:
395a3d090606bb33c46107de1ff60fe3fd6cb494f2850bcd2dfc1b8dabd46442 - Sigstore transparency entry: 591112691
- Sigstore integration time:
-
Permalink:
cjuniorfox/weathergrabber@7c20768db9ad9792d6465d269ee4a25ca0e14849 -
Branch / Tag:
refs/tags/v0.0.8a4 - Owner: https://github.com/cjuniorfox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@7c20768db9ad9792d6465d269ee4a25ca0e14849 -
Trigger Event:
release
-
Statement type:
File details
Details for the file weathergrabber-0.0.8a4-py3-none-any.whl.
File metadata
- Download URL: weathergrabber-0.0.8a4-py3-none-any.whl
- Upload date:
- Size: 47.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5166a595674c485aca997c6019e415b88a0534c7f9e49671458f65fef341316f
|
|
| MD5 |
1efe09a485b60c9b1904db7e4c6b8e73
|
|
| BLAKE2b-256 |
96376b9bd62b93eb1ef15bb6a05349ce2107ad3560c3de8147860fbdd4e44c9d
|
Provenance
The following attestation bundles were made for weathergrabber-0.0.8a4-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on cjuniorfox/weathergrabber
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weathergrabber-0.0.8a4-py3-none-any.whl -
Subject digest:
5166a595674c485aca997c6019e415b88a0534c7f9e49671458f65fef341316f - Sigstore transparency entry: 591112693
- Sigstore integration time:
-
Permalink:
cjuniorfox/weathergrabber@7c20768db9ad9792d6465d269ee4a25ca0e14849 -
Branch / Tag:
refs/tags/v0.0.8a4 - Owner: https://github.com/cjuniorfox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@7c20768db9ad9792d6465d269ee4a25ca0e14849 -
Trigger Event:
release
-
Statement type: