NukaNewsBot/utils/fetch_url.go

32 lines
509 B
Go
Raw Permalink Normal View History

2024-04-28 03:05:54 +00:00
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
}