I'm trying to use requests.get but it never works
With examples found in internet it's the same....never work
See this example the error message is:
>>> %Run -c $EDITOR_CONTENT
IP MASQ GATEWAY DNS
('192.168.1.33', '255.255.255.0', '192.168.1.254', '32.1.8.97')
Traceback (most recent call last):
File "<stdin>", line 25, in <module>
File "urequests.py", line 108, in get
File "urequests.py", line 53, in request
OSError: -202
>>>
It seems that there is something missing ????
What can I do ?
Thanks very much for any answer !!!!
Code: Select all
import network
import socket
import urequests
SSID = "MyBox"
PASSWORD = "MyPassword"
sta_if = network.WLAN(network.STA_IF)
# ap_if = network.WLAN(network.AP_IF)
# ap_if.active(False)
while not sta_if.isconnected():
sta_if.active(True)
print("connection en cours......")
sta_if.connect(SSID,PASSWORD)
if sta_if.isconnected():
print(" IP MASQ GATEWAY DNS ")
print(sta_if.ifconfig())
# attention le DNS est parfois errone !!!!!! "32.1.8.97" au lieu de '192.168.1.254'
response = urequests.get('http://jsonplaceholder.typicode.com/albums/1')
print(type(response))