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:

from google_weather.weather import WeatherScraper

# Create a scraper instance
scraper = WeatherScraper()

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

You can also specify the language, temperature unit, and wind unit:

# Get weather in Italian with Fahrenheit and mph
result = 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, Città Autonoma di Buenos Aires'}

# Get weather in English
result = scraper.get_weather('New York', lang='en')
print(result)
# {'temperature': '37.4°F', 'humidity': '40%', 'wind': '11 mph', 'condition': 'Mostly Cloudy', 'location': 'New York, NY'}

Debug Mode

You can enable debug mode to save screenshots and HTML content during scraping:

scraper = WeatherScraper(debug=True)
result = scraper.get_weather('Tokyo')

This will save screenshots and HTML files in a 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)

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.4.tar.gz (5.8 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.4-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygoogleweather-0.1.4.tar.gz
  • Upload date:
  • Size: 5.8 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.4.tar.gz
Algorithm Hash digest
SHA256 6132fa3030e20512dab42824d91f3cb9357e2b80527eeaa38b9f7314fff893f2
MD5 9fd34690a1566bec311bbde1765c7cae
BLAKE2b-256 ee9eaeeec8266c2a65e0d694ac915fcf2763226599a1866b08690cad2a91ee6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pygoogleweather-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cf1c7943b982baa60446ee82350c23c0d7bd3c02b3c804f6525487cd5af380f6
MD5 1fb5a45d7c6963bac6887e24f23391d3
BLAKE2b-256 621d18e04c9b16be22bac143337fce69519b0ff7ff88d4eec29a8649ee7a0cef

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