mirror of
https://codeberg.org/pluja/kycnot.me
synced 2025-03-29 20:37:58 -04:00
use custom Getenv with fallback
This commit is contained in:
parent
038ad49ec7
commit
7e259b7cb4
@ -7,12 +7,13 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/html"
|
"golang.org/x/net/html"
|
||||||
|
|
||||||
|
"pluja.dev/kycnot.me/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScraperResponse struct {
|
type ScraperResponse struct {
|
||||||
@ -24,10 +25,7 @@ type ScraperResponse struct {
|
|||||||
func GetBody(url string) (string, error) {
|
func GetBody(url string) (string, error) {
|
||||||
// Send a GET request to os.Getenv("SCRAPER_API_URL")/scrap?url=url
|
// Send a GET request to os.Getenv("SCRAPER_API_URL")/scrap?url=url
|
||||||
// Unmarshal the response and return the HTML content
|
// Unmarshal the response and return the HTML content
|
||||||
scraper_api := os.Getenv("SCRAPER_API_URL")
|
scraper_api := utils.Getenv("SCRAPER_API_URL", "http://localhost:3011")
|
||||||
if scraper_api == "" {
|
|
||||||
scraper_api = "http://localhost:3011"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request the HTML content
|
// Request the HTML content
|
||||||
resp, err := http.Get(fmt.Sprintf("%v/scrap?url=%v", scraper_api, url))
|
resp, err := http.Get(fmt.Sprintf("%v/scrap?url=%v", scraper_api, url))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user