import requests from urllib.parse import quote import re lua = ''' function main(splash, args) local treat = require("treat") local response = splash:http_get("http://httpbin.org/get") return treat.as_string(response.body) end ''' url = 'http://0.0.0.0:8050/execute?lua_source=' + quote(lua) response = requests.get(url, auth=('admin', 'qq562246926')) ip = re.search('(d+.d+.d+.d+)', response.text).group(1) print(ip)