❔ 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])
🍿 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: