
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Asynchronous Python library for accessing Turkish Meteorology General Directorate (MGM) data
MGMScraper is an asynchronous Python library for extracting weather and climate data from the Turkish Meteorology General Directorate (MGM) website (mgm.gov.tr). It provides a clean, modular API for retrieving observations, forecasts, statistics, and radar imagery with minimal dependencies.
asyncio
patterns for high-performance scrapingStationService
, ForecastService
) lives in its own module, simplifying extension and maintenanceaiohttp
and beautifulsoup4
pip install mgmscraper
import asyncio
from mgmscraper import HttpClient, StationService
async def main():
async with HttpClient() as session:
station_service = StationService(session)
# Get all province centers
provinces = await station_service.get_province_centers()
print(f"Found {len(provinces)} provinces")
# Get stations in a specific province
istanbul_stations = await station_service.get_province_stations("İstanbul")
print(f"Found {len(istanbul_stations)} stations in İstanbul")
if __name__ == "__main__":
asyncio.run(main())
import asyncio
from mgmscraper import HttpClient, ObservationService
async def main():
async with HttpClient() as session:
obs_service = ObservationService(session)
# Get current weather for İstanbul (province plate code: 34)
istanbul_weather = await obs_service.get_by_province_plate(34)
for station in istanbul_weather:
print(f"{station['istNo']}: {station['sicaklik']}°C")
if __name__ == "__main__":
asyncio.run(main())
import asyncio
from mgmscraper import HttpClient, ForecastService
async def main():
async with HttpClient() as session:
forecast_service = ForecastService(session)
# Get hourly forecast for a station (example station ID: 17130)
hourly_forecast = await forecast_service.get_hourly_forecast(17130)
if hourly_forecast:
print(f"Hourly forecast for {hourly_forecast['merkez']}:")
for hour in hourly_forecast["tahmin"]:
print(f" {hour['tarih']}: {hour['sicaklik']}°C")
if __name__ == "__main__":
asyncio.run(main())
import asyncio
from mgmscraper import HttpClient, DailyStatsService
async def main():
async with HttpClient() as session:
# Get statistics for January 1, 2024
daily_stats = DailyStatsService(session, "2024-01-01")
# Get highest temperatures of the day
highest_temps = await daily_stats.get_highest_temperature()
if highest_temps:
print("Highest temperatures:")
for record in highest_temps[:5]: # Show top 5
print(f" {record['istAd']}: {record['deger']}°C")
if __name__ == "__main__":
asyncio.run(main())
import asyncio
from mgmscraper import HttpClient, MonthlyStatsService
async def main():
async with HttpClient() as session:
monthly_stats = MonthlyStatsService(session, "İstanbul")
# Get general monthly statistics
general_stats = await monthly_stats.get_general_stats()
if general_stats:
print("İstanbul Monthly Statistics:")
for param, values in general_stats.items():
print(f" {param}: {values}")
if __name__ == "__main__":
asyncio.run(main())
import asyncio
from mgmscraper import HttpClient, RadarService
async def main():
async with HttpClient() as session:
radar_service = RadarService(session)
# Get available radar details
radar_details = await radar_service.get_details()
print("Available radars:")
for radar_name in radar_details.keys():
print(f" - {radar_name}")
# Get radar image (example: İstanbul radar, PPI product, image #1)
image_data = await radar_service.get_image("İstanbul", "ppi", 1)
if image_data:
with open("istanbul_radar.jpg", "wb") as f:
f.write(image_data)
print("Radar image saved as istanbul_radar.jpg")
if __name__ == "__main__":
asyncio.run(main())
get_station(province_name, district_name)
: Get specific station infoget_province_centers()
: Get all province centersget_province_stations(province_name)
: Get all stations in a provinceget_ski_stations()
: Get ski resort stationsget_by_istno(sondurumIstNo)
: Get current weather by station IDget_by_merkezid(merkezid)
: Get current weather by center IDget_by_province_plate(plate_code)
: Get all current weather data for a provinceget_province_centers()
: Get province center listget_province_stations(province_name)
: Get station list for a provinceget_snow_depth()
: Get snow depth observationsget_hourly_forecast(saatlikTahminIstNo)
: Get hourly forecast for a stationget_daily_forecast(gunlukTahminIstNo)
: Get daily forecast for a stationget_highest_temperature()
: Get daily highest temperaturesget_lowest_temperature()
: Get daily lowest temperaturesget_lowest_soil_temperature()
: Get daily lowest soil temperaturesget_total_precipitation()
: Get daily total precipitationget_historical_extremes(merkezid)
: Get historical extremes for a dateget_general_stats()
: Get general monthly statisticsget_seasonal_norms()
: Get seasonal norm dataget_details()
: Get available radar informationget_image(radar_name, product, number)
: Get radar imagesfrom mgmscraper import HttpClient
# Configure client with custom settings
async with HttpClient(
timeout=120, # Request timeout in seconds
max_retries=5, # Maximum retry attempts
calls_per_second=1.0, # Rate limiting
max_connections=50, # Connection pool size
ssl_verify=True # SSL verification
) as session:
# Your code here
pass
import asyncio
from mgmscraper import HttpClient, ObservationService
async def main():
try:
async with HttpClient() as session:
obs_service = ObservationService(session)
data = await obs_service.get_by_province_plate(34)
if data is None:
print("No data available")
else:
print(f"Retrieved {len(data)} observations")
except Exception as e:
print(f"Error occurred: {e}")
if __name__ == "__main__":
asyncio.run(main())
We welcome contributions! Here's how to get started:
git checkout -b feature/amazing-feature
)git commit -m "Add amazing feature"
)git push origin feature/amazing-feature
)Please ensure your code follows the existing style and includes appropriate documentation.
This project is licensed under the MIT License. See the LICENSE file for details.
This library is for educational and research purposes. Please respect MGM's servers by:
All data is sourced from the Turkish Meteorology General Directorate (MGM):
FAQs
Asynchronous Python library for accessing Turkish Meteorology General Directorate (MGM) data
We found that mgmscraper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.