MCPcopy Create free account
hub / github.com/PuerkitoBio/goquery / ExampleNewDocumentFromReader_file

Function ExampleNewDocumentFromReader_file

example_test.go:47–60  ·  view source on GitHub ↗

This example shows how to use NewDocumentFromReader from a file.

()

Source from the content-addressed store, hash-verified

45
46// This example shows how to use NewDocumentFromReader from a file.
47func ExampleNewDocumentFromReader_file() {
48 // create from a file
49 f, err := os.Open("some/file.html")
50 if err != nil {
51 log.Fatal(err)
52 }
53 defer f.Close()
54 doc, err := goquery.NewDocumentFromReader(f)
55 if err != nil {
56 log.Fatal(err)
57 }
58 // use the goquery document...
59 _ = doc.Find("h1")
60}
61
62// This example shows how to use NewDocumentFromReader from a string.
63func ExampleNewDocumentFromReader_string() {

Callers

nothing calls this directly

Calls 2

NewDocumentFromReaderFunction · 0.92
FindMethod · 0.80

Tested by

no test coverage detected