github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/chat/unfurl/scraper/main.go (about) 1 package main 2 3 import ( 4 "context" 5 "flag" 6 "fmt" 7 "os" 8 9 "github.com/keybase/client/go/chat/globals" 10 "github.com/keybase/client/go/chat/unfurl" 11 "github.com/keybase/client/go/libkb" 12 ) 13 14 func main() { 15 flag.Parse() 16 args := flag.Args() 17 if len(args) != 1 { 18 fmt.Printf("must supply a URL\n") 19 os.Exit(3) 20 } 21 22 url := args[0] 23 // Run it with an empty global context. Will only impact proxy support 24 scraper := unfurl.NewScraper(globals.NewContext(libkb.NewGlobalContextInit(), &globals.ChatContext{})) 25 res, err := scraper.Scrape(context.TODO(), url, nil) 26 if err != nil { 27 fmt.Printf("error scraping URL: %v\n", err) 28 os.Exit(3) 29 } 30 fmt.Printf("%s\n", res.UnsafeDebugString()) 31 }