Page 1 of 1

Issue with curl

Posted: Sun Aug 26, 2018 9:40 am
by fdufnews
Hi,
here is the configuration I use:
Lilygo T4 board with ESP32 and SPIRAM
MicroPython ESP32_LoBo_v3.2.20 - 2018-06-28 on ESP32 board with ESP32

I use curl to get a json file from wunderground weather forecast using their API

Code: Select all

import curl, ujson
res=curl.get('http://api.wunderground.com/api/my_access_key/conditions/lang:FR/q/pws:ILEDEFRA179.json')
objjson = ujson.loads(res[2])
res[0] returns 0
and res[2] contains the json data
The problem is that some characters are modified leading to an error when res[2] is parsed with ujson.loads(res[2])
I have investigated to understand where the problem is
I found that in res[2] there are . (ASCII 46)
term.png
term.png (93.37 KiB) Viewed 4920 times
When I substitute a space to the . the string is parsed without error
In a console, I ran a:

Code: Select all

GET -o text http://api.wunderground.com/api/my_access_key/conditions/lang:FR/q/pws:ILEDEFRA179.json > conditions.txt
I opened the file with GHEX
GHEX.png
GHEX.png (113.53 KiB) Viewed 4920 times
There are tabs in the file where I find . in res[2].
Where are those . coming from?
As far as I understand, the curl module in loboris version is the same as the one in official MicroPython.

Re: Issue with curl

Posted: Sun Aug 26, 2018 4:21 pm
by loboris
Curl GET was filtering all characters less than 32 (except \r & \n) replacing them with '.'
I'll enable the tab (0x09) character to be passed to the result too. The repository update is planned for tomorrow.

Re: Issue with curl

Posted: Sun Aug 26, 2018 6:55 pm
by fdufnews
Cooool
Thanks a lot

Re: Issue with curl

Posted: Thu May 28, 2020 6:12 am
by mkcastillote
Hello,
How do you install the curl library on NodeMCU?
Thank you!