Here is a test script:
"""
DavidLibeau
"""
import http.client
import sims4.commands
import services
@sims4.commands.Command('curl', command_type=sims4.commands.CommandType.Live)
def curl(url: str = 'dav.li/log/', _connection: int = None): # go to http://dav.li/log/log.txt to see the last time the website was reached
output = sims4.commands.CheatOutput(_connection)
output('Performing curl on: ' + url)
headers = {
"user-agent": "The Sims 4 (curl mod) dav.li"
}
url = url.split("/")
path = ""
if len(url) > 1:
path = url[1]
url = url[0].split(":")
port = ""
if len(url) > 1:
port = url[1]
url = url[0]
try:
output(url+'|'+port+'|'+path)
conn = http.client.HTTPConnection(url, port)
conn.request("GET", path, "", headers)
res = conn.getresponse()
res.body = str(res.read(), "UTF-8")
conn.close()
output('Curl performed without error. Content-length:' + len(res.body))
return
except OSError as err:
output(err.strerror)
return
I have a "Can't assign requested address" when I run it and, again, everything was perfectly working in November.