Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4045

MicroPython • Re: Multiple API Requests with Pi Pico W

$
0
0
is there any way I could make multiple requests with separate urls from this lightweight version of Requests?
Perhaps explain what you mean by "multiple requests", or detail what isn't working for you, because getting data from multiple URL's works for me.

Code:

import requestsimport secretsimport networkimport timewlan = network.WLAN(network.STA_IF)wlan.active(True)wlan.connect(secrets.ssid, secrets.password)while not wlan.isconnected():    print("waiting for connection...")    time.sleep(1)print("connected")def Report(url):  print(url)  reply = requests.get(url)  headers = reply.headers  content = reply.content  reply.close()  print(content)Report("http://ident.me")Report("https://api.wheretheiss.at/v1/satellites/25544")

Code:

connectedhttp://ident.meb'XXX.XXX.XXX.XXX'https://api.wheretheiss.at/v1/satellites/25544b'{"name":"iss","id":25544,"latitude":-24.226773950599,"longitude":172.27974314092,"altitude":418.32484432481,"velocity":27589.173482743,"visibility":"eclipsed","footprint":4498.9311827822,"timestamp":1719228725,"daynum":2460485.9806134,"solar_lat":23.393615499542,"solar_lon":7.6232388473692,"units":"kilometers"}'

Statistics: Posted by hippy — Mon Jun 24, 2024 11:41 am



Viewing all articles
Browse latest Browse all 4045

Trending Articles