NukaNewsBot/utils/fetch_url.go

32 lines
509 B
Go

package utils
import (
"context"
"log"
"github.com/chromedp/chromedp"
)
func FetchUrl(url string) string {
// Create a new context
ctx := context.Background()
ctx, cancel := chromedp.NewContext(
ctx,
chromedp.WithLogf(log.Printf),
)
defer cancel()
// Navigate to the Fallout news page
var html string
err := chromedp.Run(ctx, chromedp.Tasks{
chromedp.Navigate(url),
chromedp.OuterHTML("html", &html),
})
if err != nil {
log.Fatal(err)
}
// Return the HTML content
return html
}