use custom Getenv with fallback

This commit is contained in:
pluja 2024-02-05 07:39:13 +01:00
parent 038ad49ec7
commit 7e259b7cb4

View File

@ -7,12 +7,13 @@ import (
"math/rand"
"net/http"
"net/http/cookiejar"
"os"
"regexp"
"strings"
"time"
"golang.org/x/net/html"
"pluja.dev/kycnot.me/utils"
)
type ScraperResponse struct {
@ -24,10 +25,7 @@ type ScraperResponse struct {
func GetBody(url string) (string, error) {
// Send a GET request to os.Getenv("SCRAPER_API_URL")/scrap?url=url
// Unmarshal the response and return the HTML content
scraper_api := os.Getenv("SCRAPER_API_URL")
if scraper_api == "" {
scraper_api = "http://localhost:3011"
}
scraper_api := utils.Getenv("SCRAPER_API_URL", "http://localhost:3011")
// Request the HTML content
resp, err := http.Get(fmt.Sprintf("%v/scrap?url=%v", scraper_api, url))