28.07.2020, 07:10
You can override default user agent like this. This example uses LM MAC address to create a unique number for the user agent string.
Code:
json = require('json')
http = require('socket.http')
url = 'https://api.met.no/weatherapi/locationforecast/2.0/complete?lat=67.8596&lon=35.0904&altitude=13'
mac = 0
io.readfile('/sys/class/net/eth0/address'):gsub('%x%x', function(v)
mac = mac * 256 + tonumber(v, 16)
end)
http.USERAGENT = 'LM ' .. mac
res, err = http.request(url)
log(res, err)