I Have a Python program that gives the output as the following:
from bs4 import BeautifulSoup
html = `<h1>This is heading</h1> <p>this is parah <strong>strong</strong> that\'s how it works</p>`
parsed_html = BeautifulSoup(html, 'html.parser')
all_lines = parsed_html.findAll(text=True)
print(all_lines)
# ['This is heading', ' ', 'this is parah ', 'strong', " that's how it works"]
I am trying to achieve the same in golang but not able to get the required output. so far what I have tried:
import (
"fmt"
"strings"
"github.com/PuerkitoBio/goquery"
)
func parseHTML(body string) string {
p := strings.NewReader(body)
doc, _ := goquery.NewDocumentFromReader(p)
fmt.Println(doc.Text())
// output: This is heading this is parah strong thats how it works
}