🤖 Pair-programming w. ChatGPT to get live Beaches quality Water at Nouméa🏖️

adriens - Mar 9 '23 - - Dev Community

❔ About

I wanted to go to the beach at Nouméa, New Caledonia. ... and wanted to know:

🗺️ Where are the beaches
🧫 Their water quality

💡 So I asked myself if...

ChatGPT could help with doing that with a Python script for automation tasks.

🎤 What you'll learn

👉 In this short post you'll discover how I could co-author a script with ChatGPT from scratch 🙀.

🍿 Demo time (< 7')

🐍 Original Source code

#!/usr/bin/env python3

import requests
from bs4 import BeautifulSoup

# Make a GET request to the webpage
url = 'https://www.noumea.nc/noumea-pratique/salubrite-publique/qualite-eaux-baignade'
response = requests.get(url)

# Parse the HTML content of the page with BeautifulSoup
soup = BeautifulSoup(response.content, 'html.parser')

# Find the table element containing the beach data by class name
beach_table = soup.find('table', class_='table')

# Extract the beach names and flag colors from the table
beach_data = []
for row in beach_table.find_all('tr')[1:]:
    columns = row.find_all('td')
    beach_name = columns[0].get_text().strip()
    flag_color = columns[1].find('img')['alt']
    beach_data.append((beach_name, flag_color))

# Print the beach data
for beach in beach_data:
    print(beach[0] + ': ' + beach[1])
Enter fullscreen mode Exit fullscreen mode

🍿 Opportunties

As I showed this work to my girlfriend, she asked :

"You got the beaches status in text... now what ? Why is it cool ?"

To answer the question, I told here that it makes it possible to contribute to build Smartcities, to create "programs for robots" (eg. API) can help making cool things like @BotCagou
:

Below are some works I did thanks to API on this topic : a twiiter BOT :

📑 Resources

Below a collection of innovations I did thanks to the API I built once a while:

Open Data & public APIs : founding together the collaborative & Open Sourced Smart City.

How many times did you hear people talk about Open Data,..

favicon linkedin.com

Air & Eau : la convergence des éléments via les indicateurs... à l'Anse Vata, le spot mythique de Windsurf.

A Nouméa, nous aimons les alizés et l'océan, aussi nous sommes très sensibles à deux facteurs : la qualité de l'eau et la qualité de l'air. Pour cela nous disposons de deux entités bien distinctes : la Mairie de Nouméa pour la qualité des eaux de baignade, Scal-Air pour l'air.

favicon linkedin.com

Building Smartcities : how I started from scratch with a website and ended by create an AR (Augmnented Reality) experience

See how implementing a REST API, build badges and an html responsive slideshow, then a Twitter BOT can help implement a decent first and very fun AR experience to share. Since almost more than a year I started a journey into sharing datas through API to show their power.

favicon linkedin.com

Let Twitter BOTs tell you when you can (or not) go to swim

It's very common, for most SaaS providers (Github, Travis CI, Heroku,..

favicon linkedin.com

Geek@beach : get water quality straight outta svg badges and augment reality with them !

As a DevOps, you probably love & make an extensive use of badges (ie. shields) for almost everything (build, code coverage, dependencies, downloads, a backup or replication status,.

favicon linkedin.com
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .