kpcyrd/telefonbuch-reverse
function run(arg)
session = http_mksession()
query = arg['value']
query = query:gsub('+', '%%2B')
url = 'https://www.dastelefonbuch.de/R%C3%BCckw%C3%A4rts-Suche/' .. query
req = http_request(session, 'GET', url, {})
r = http_send(req)
if last_err() then return end
if r['status'] == 410 then return end
if r['status'] ~= 200 then return 'http error: ' .. r['status'] end
x = html_select(r['text'], '#entry_1 div')
name = x['attrs']['title']
db_update('phonenumber', arg, {
caller_name=name,
})
end