-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
30 lines (27 loc) · 1.04 KB
/
example_test.go
File metadata and controls
30 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package urlinfo_test
import (
"encoding/json"
"os"
"github.com/mdigger/urlinfo"
)
func Example() {
info := urlinfo.Get("https://edition.cnn.com/2018/08/11/politics/donald-trump-vacation-new-jersey/index.html")
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(info)
// Output:
// {
// "url": "https://edition.cnn.com/2018/08/11/politics/donald-trump-vacation-new-jersey/index.html",
// "status": 200,
// "mediaType": "text/html; charset=utf-8",
// "title": "Peek inside Trump's total non-vacation in New Jersey",
// "description": "For President Donald Trump, the long-standing image of a leader in repose doesn't apply, at least in his own mind. In New Jersey this week, events were arranged to demonstrate his extended stay at a wooded golf resort was, in fact, work.",
// "author": "Kevin Liptak and Jeff Zeleny, CNN",
// "image": "https://cdn.cnn.com/cnnnext/dam/assets/170611140113-trump-golfing-super-tease.jpg",
// "keywords": [
// "politics"
// ],
// "type": "article",
// "site": "CNN"
// }
}