Skip to main content

Python library to get weather from Google Search. No API keys required.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

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

  1. Install the library using pip:
pip install pygoogleweather
  1. Install Playwright's browser (required):
playwright install chromium

Usage

Basic Usage (Regular Python Environment)

import asyncio
from google_weather.weather import WeatherScraper

async def main():
    # Create a scraper instance
    scraper = WeatherScraper()

    # Get weather for a city
    result = await scraper.get_weather('Buenos Aires')
    print(result)
    # {'temperature': '24.0°C', 'humidity': '72%', 'wind': '34 kmh', 'condition': 'Mayormente soleado', 'location': 'Buenos Aires, Argentina'}

# Run the async function
asyncio.run(main())

Custom Options

async def main():
    scraper = WeatherScraper()
    
    # Get weather in Italian with Fahrenheit and mph
    result = await scraper.get_weather(
        'Buenos Aires', 
        lang='it',
        temp_unit='F',
        wind_unit='mph'
    )
    print(result)
    # {'temperature': '75.2°F', 'humidity': '72%', 'wind': '21 mph', 'condition': 'Per lo più soleggiato', 'location': 'Buenos Aires, Argentina'}

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

# Import and use
from google_weather.colab import ColabWeatherClient

# Create client
weather = ColabWeatherClient()

# Get weather data
result = weather.get_weather('New York', lang='en')
print(result)
# {'location': 'New York', 'temperature': '19.4°F', 'condition': 'Sunny', 'humidity': '57%', 'wind': '2 mph'}

# With custom units
result = weather.get_weather(
    'Paris',
    lang='fr',
    temp_unit='C',
    wind_unit='kmh'
)
print(result)
# {'location': 'Paris', 'temperature': '9.0°C', 'condition': 'Nuageux', 'humidity': '85%', 'wind': '6 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 name
  • lang (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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygoogleweather-0.1.10.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygoogleweather-0.1.10-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file pygoogleweather-0.1.10.tar.gz.

File metadata

  • Download URL: pygoogleweather-0.1.10.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for pygoogleweather-0.1.10.tar.gz
Algorithm Hash digest
SHA256 25c77349d76b44e6b6188a3ee8ac6e68a2dbb4b5e43db1294111049c70a77650
MD5 fc6a34501648161ccc3e9787d23df230
BLAKE2b-256 e6e3496f4477020c3e08009df142bccb1ea299aeecff17377f105be2008ec5a1

See more details on using hashes here.

File details

Details for the file pygoogleweather-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for pygoogleweather-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 3ee85ff51638dc45805573bec2491b187795916dace3d76c510a67d51de8d912
MD5 a109c3c547b3cb2c1036b8652c5ea2d6
BLAKE2b-256 e43f055789c5810c8d0dbbe279280be27a13e340c6497628ba2e9a52b37e4b46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page