Grist formulas run in a secure sandbox without access to the network. Here is an answer to a similar question:
If running a self-managed server, there is an experimental REQUEST
function you can enable while running code in a sandbox. See this thread: Python requests package.
In normal hosted Grist (on getgrist.com), there is no way for formulas to talk to the outside world. The other options are the REST API (where you are responsible to running your script), integrator services, and Custom Widgets.