RosettaCodeData/Task/HTTP/Sidef/http.sidef

13 lines
251 B
Text
Raw Permalink Normal View History

2023-12-16 21:33:55 -08:00
require('HTTP::Tiny')
2023-07-01 11:58:00 -04:00
func get(url) {
2023-12-16 21:33:55 -08:00
static ua = %O<HTTP::Tiny>.new(agent => 'Mozilla/5.0')
var resp = ua.get(url)
if (resp{:success}) {
return resp{:content}.decode_utf8
2023-07-01 11:58:00 -04:00
}
return nil
}
2023-12-16 21:33:55 -08:00
say get("http://rosettacode.org")