DEV Community

Alex Spinov
Alex Spinov

Posted on

5 Python Scripts That Replaced My Browser Tabs (With Code)

I used to have 15+ browser tabs open every morning: weather, stock prices, news, ISS position (yes really), exchange rates.

Then I wrote 5 Python scripts that fetch all that data in under 2 seconds. Now I run one command and get everything in my terminal.

Here they are.

1. Weather Dashboard (Open-Meteo API)

import requests

def weather(lat, lon):
    r = requests.get(f'https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}&current_weather=true')
    w = r.json()['current_weather']
    print(f'Weather: {w["temperature"]}C, wind {w["windspeed"]}km/h')

weather(55.75, 37.62)  # Moscow
Enter fullscreen mode Exit fullscreen mode

Replaced: weather.com tab

2. Crypto Portfolio Check (CoinGecko)

import requests

def crypto():
    coins = 'bitcoin,ethereum,solana'
    r = requests.get(f'https://api.coingecko.com/api/v3/simple/price?ids={coins}&vs_currencies=usd&include_24hr_change=true')
    for name, data in r.json().items():
        print(f'{name}: ${data["usd"]:,.0f} ({data["usd_24h_change"]:+.1f}%)')

crypto()
Enter fullscreen mode Exit fullscreen mode

Replaced: CoinMarketCap tab

3. Exchange Rates (Open Exchange Rates)

import requests

def rates():
    r = requests.get('https://open.er-api.com/v6/latest/USD')
    data = r.json()['rates']
    for cur in ['EUR', 'GBP', 'JPY', 'RUB']:
        print(f'1 USD = {data[cur]:.2f} {cur}')

rates()
Enter fullscreen mode Exit fullscreen mode

Replaced: Google "USD to EUR" tab

4. Who Is In Space Right Now (Open Notify)

import requests

def space():
    r = requests.get('http://api.open-notify.org/astros.json')
    data = r.json()
    print(f'{data["number"]} humans in space:')
    for p in data['people']:
        print(f'  {p["name"]} on {p["craft"]}')

space()
Enter fullscreen mode Exit fullscreen mode

Replaced: nasa.gov tab I checked weekly

5. Top Hacker News Stories

import requests

def hackernews(n=5):
    ids = requests.get('https://hacker-news.firebaseio.com/v0/topstories.json').json()[:n]
    for i in ids:
        story = requests.get(f'https://hacker-news.firebaseio.com/v0/item/{i}.json').json()
        print(f'{story.get("score",0)} pts | {story.get("title","")} ')

hackernews()
Enter fullscreen mode Exit fullscreen mode

Replaced: news.ycombinator.com tab

Combine Them All

if __name__ == '__main__':
    print('=== MORNING DASHBOARD ===')
    weather(55.75, 37.62)
    print()
    crypto()
    print()
    rates()
    print()
    space()
    print()
    hackernews()
Enter fullscreen mode Exit fullscreen mode

Run time: ~1.5 seconds for all 5. Zero API keys. Zero cost.

I maintain Python clients for all these APIs if you want ready-made wrappers.

What browser tab would you automate first?

Top comments (0)