Convert an HTML Document to Word in Go

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/convert/html/to/docx"
method := "POST"
payload := strings.NewReader("Html=%3Cstring%3E")client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

--

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Hyprr Node Snapshot — August 14th at 4pm BST

CS371p Spring 2022 Blog #2: Lilia Li

How to use Binance Chain Staking Tool?

Leaving no-code ? No so fast !

Automate Excel with Python

Rust Async Actix-Web Middleware

Email forwarding to Gmail from Bluehost

Feature Flags explained with Laravel

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

More from Medium

Not a Regular Password Regex

Handling Private Affair: A Guide to Secrets Management System

Go — If/Else, Switch, and For loop

Git let’s Go