Hello all !
I want to send, via a Python script, the value of the Safran stock retrieved from the Boursorama website to the Arduino Cloud.
I managed to code the script below, but the sending only occurs once
import logging
import sys
import time
sys.path.append("lib")
from arduino_iot_cloud import ArduinoCloudClient
import requests
from bs4 import BeautifulSoup
DEVICE_ID = b"xxx"
SECRET_KEY = b"xxx"
def logging_func():
logging.basicConfig(
datefmt="%H:%M:%S",
format="%(asctime)s.%(msecs)03d %(message)s",
level=logging.INFO,
)
def get_value_from_boursorama():
requete = requests.get("https://www.boursorama.com/cours/1rPSAF/")
page = requete.content
soup = BeautifulSoup(page, 'lxml')
h1 = soup.find("span", {"class": "c-instrument c-instrument--last"})
return h1.string
if __name__ == "__main__":
logging_func()
client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
client.register('datavalue')
client['datavalue'] = float(get_value_from_boursorama())
client.start()
I'm a beginner in programming, and the API documentation isn't clear to me. Does the API allow this? If so, how?
Thank you in advance
3 posts - 2 participants