You can make a HTTP request and send a custom HTML body in Python using the http.client module. Here's an example:
main.py482 chars21 lines
In this example, we're making a HTTPS request to www.example.com with a custom HTML body containing a h1 tag. We set the headers to indicate that the body is in the HTML format. Finally, we send the request using the request() method with the HTTP method (POST), the API endpoint (/path/to/api), the custom HTML body, and the headers. We then get the response using the getresponse() method, and print the response status and body.
gistlibby LogSnag