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?


More from me: 10 Dev Tools I Use Daily | 77 Scrapers on a Schedule | 150+ Free APIs


Need web scraping or data extraction? I've built 77+ production scrapers. Email spinov001@gmail.com — quote in 2 hours. Or try my ready-made Apify actors — no code needed.

Top comments (2)

Collapse
 
omega_alphatron_0101 profile image
Omega Alphatron

This looks cool, I got some brainstorming session in today with what to do with these.
So how do you implement these.. do you have them as a Wrapper through DevTools, extension maybe?

"Python clients" 🔗 is 4️⃣0️⃣4️⃣.

Collapse
 
0012303 profile image
Alex Spinov

Two answers, and the first one is an apology.

The 404 was real. That link points at a GitHub profile that has had its own trouble; it resolves again today, I checked just now and got a 200. I cannot reconstruct why it was dead on the day you looked, so I am not going to invent a reason. What is actually behind it is a pile of repos bulk-created over a couple of days in March, which is a weaker thing than "Python clients I maintain" implies. Fair catch on both counts.

On the implementation: nothing clever, and no browser anywhere in it. Five plain functions in one .py file, run from a terminal. import requests, hit a public HTTP endpoint that needs no key, print the line. No DevTools hook, no extension, no headless anything. The ~1.5 seconds is five GETs and some printing.

If you want them to genuinely replace tabs rather than be a script you remember to run, the missing piece is a cron entry or a shell alias, not a wrapper.