Post-Migrator/services/slowtwitch/get-page-status.go

28 lines
359 B
Go
Raw Normal View History

package slowtwitch
import (
"fmt"
"io"
"net/http"
"strings"
)
func GetPageStatus(url string) int {
response, err := http.Get(url)
if err != nil {
fmt.Println(err)
}
defer response.Body.Close()
bytes, _ := io.ReadAll(response.Body)
html := string(bytes)
if strings.Contains(html, "<h2>Error</h2>") {
return 404
} else {
return 200
}
}