This project has been archived by its maintainers, and is no longer receiving any updates.
pygoogleweather
pygoogleweather is a Python library to get weather information from Google Search. No API keys required.
Features
- Fetch current weather information for any city
- Supports multiple languages
- Convert temperature units between Celsius, Fahrenheit, and Kelvin
- Get wind speed in km/h or mph
- Reliable web scraping using Playwright
Installation
- Install the library using pip:
pip install pygoogleweather
- Install Playwright's browser (required):
playwright install chromium
Usage
Basic Usage
from google_weather.weather import get_weather_sync
# Get weather for a city (returns a dictionary with weather information)
result = get_weather_sync('Buenos Aires')
print(result)
# Output:
# {
# 'temperature': '24.0°C',
# 'humidity': '72%',
# 'wind': '34 km/h',
# 'condition': 'Mostly sunny',
# 'location': 'Buenos Aires, Argentina'
# }
Advanced Usage (with async)
import asyncio
from google_weather.weather import WeatherScraper
async def main():
# Create a scraper instance with custom options
scraper = WeatherScraper(headless=True, debug=False)
try:
# Get weather with custom language and units
result = await scraper.get_weather(
city='Paris',
lang='fr', # French language
temp_unit='F', # Fahrenheit
wind_unit='mph' # Miles per hour
)
print(result)
finally:
# Always close the scraper to free resources
await scraper.close()
# Run the async function
asyncio.run(main())
Using in Google Colab
The library provides a special client for Google Colab that handles all the async complexity for you:
# Install
!pip install pygoogleweather
!playwright install chromium
from google_weather.colab import ColabWeatherClient
# Crear cliente
weather = ColabWeatherClient()
# Buenos Aires
result = weather.get_weather('Buenos Aires', lang='es')
print("\nBuenos Aires (ES):")
print(result)
# Buenos Aires (ES):
# {'location': 'Buenos Aires, Cdad. Autónoma de Buenos Aires, Argentina', 'temperature': '26.7°C', 'condition': 'Parcialmente nublado', 'humidity': '53%', 'wind': '12.0 km/h'}
# New York
result = weather.get_weather('New York', lang='en', temp_unit='F', wind_unit='mph')
print("\nNew York (EN, °F, mph):")
print(result)
# New York (EN, °F, mph):
# {'location': 'New York, NY', 'temperature': '30.0°F', 'condition': 'Partly cloudy', 'humidity': '45%', 'wind': '6.0 mph'}
# Paris
result = weather.get_weather('Paris', lang='fr', temp_unit='C', wind_unit='kmh')
print("\nParis (FR, °C, kmh):")
print(result)
# Paris (FR, °C, kmh):
# {'location': 'Paris, France', 'temperature': '3.9°C', 'condition': 'Nuageux', 'humidity': '93%', 'wind': '12.0 km/h'}
Debug Mode
You can enable debug mode to save screenshots during scraping:
scraper = WeatherScraper(debug=True) # Screenshots will be saved in 'debug_screenshots' directory
Options
The WeatherScraper class accepts these parameters:
headless(bool): Run browser in headless mode (default: True)debug(bool): Enable debug mode with screenshots (default: False)
The get_weather method accepts:
city(str): City namelang(str): Language code (default: 'en')temp_unit(str): Temperature unit ('C', 'F', or 'K', default: 'C')wind_unit(str): Wind speed unit ('kmh' or 'mph', default: 'kmh')
Requirements
- Python 3.9+
- Playwright
- Chromium browser (installed via
playwright install) - nest-asyncio (for Google Colab usage)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for pygoogleweather 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygoogleweather-0.1.12.tar.gz | 10.5 kB | Without provenance | Details for pygoogleweather-0.1.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pygoogleweather-0.1.12-py3-none-any.whl | Python 3 | none | any | Details for pygoogleweather-0.1.12-py3-none-any.whl |
Total release size: 20.1 kB
Release files / pygoogleweather-0.1.12.tar.gz
| Download URL | pygoogleweather-0.1.12.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8a520a216ad1845313f9b371f0b8c361cbdec5ec2e42fb23872154d8a8e6625
|
|
BLAKE2b-256 checksum How to use checksums |
85da7f358173bad0ec7743c0a847f22800df985aa559257026f5cefd7d37e576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / pygoogleweather-0.1.12-py3-none-any.whl
| Download URL | pygoogleweather-0.1.12-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fccf78d968100085ebed068795df34badce14718b3aaaff28723b3eb33a51643
|
|
BLAKE2b-256 checksum How to use checksums |
39d0cf1ab529185e076728e51e7af79bfb0be4d79fa91936b8d3a90e20db990e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for pygoogleweather 0.1.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.