Works like a charm ! thanks :)

and if it's a json (like http://ifconfig.co/json) ?

I tried to create this simple json parser function, but I think I'm missing 
something :

def parse_json(body)
    x = json_loads(body)
    return (x["asn_org"])

...

widget.GenPollUrl(url="http://ifconfig.co/json",parse=parse_json)

not a lot of documentation online :\
Le dimanche 22 novembre 2020 à 22:31:47 UTC+1, elParaguayo a écrit :

> Marc,
>
> Looking at the source, yes, you do need a parser but, here, it can be 
> really basic as you just want all the text from the web address.
>
> Try this:
>
> widget.GenPollUrl(url="http://ifconfig.co/country-iso";, json=False, 
> parse=lambda x: x.strip())
>
> The parser function just runs the strip function on the text you get back 
> which removes the trailing new line. Also, the widget defaults to expecting 
> json so you need to turn that off too.
>
> On Sunday, 22 November 2020 at 21:10:18 UTC odea wrote:
>
>>
>> Hi,
>> I'm a bit confused with the widget.GenPollUrl() function, do I really 
>> have to create a parser myself ? The URL I'm querying is this one : 
>> http://ifconfig.co/country-iso and I just have one word as a result.
>> If I have to create a parser, if someone could give me the code for a 
>> very simple one that would be great !
>> Thanks for your help,
>> Rgds
>> Marc
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/cfa5434a-f529-4265-8275-8564336e9d2cn%40googlegroups.com.

Reply via email to