Issue with curl

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
fdufnews
Posts: 35
Joined: Mon Jul 25, 2016 11:31 am

Issue with curl

Post by fdufnews » Sun Aug 26, 2018 9:40 am

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 2126 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 2126 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.

loboris
Posts: 322
Joined: Fri Oct 02, 2015 6:19 pm

Re: Issue with curl

Post by loboris » Sun Aug 26, 2018 4:21 pm

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.

fdufnews
Posts: 35
Joined: Mon Jul 25, 2016 11:31 am

Re: Issue with curl

Post by fdufnews » Sun Aug 26, 2018 6:55 pm

Cooool
Thanks a lot

User avatar
mkcastillote
Posts: 4
Joined: Mon Mar 16, 2020 10:35 am

Re: Issue with curl

Post by mkcastillote » Thu May 28, 2020 6:12 am

Hello,
How do you install the curl library on NodeMCU?
Thank you!

Post Reply