mirror of
https://github.com/Dvorinka/beszel.git
synced 2026-06-03 21:02:56 +00:00
b6f40af67f
Build Docker images / Hub (push) Failing after 52s
Implement enhanced WHOIS lookup strategies, specifically targeting .eu domains through EURid web scraping and alternative services to improve data accuracy for expiry dates. - Add EURid web scraping and alternative WHOIS service support for .eu domains - Increase timeouts for .eu domain lookups in TCP and native WHOIS - Improve domain scheduler to prevent overwriting valid data with zero-value dates - Enhance site UI with subdomain indicators in domain tables - Add filtering capabilities to the calendar view - Implement drag-and-drop reordering for systems table - Add new debug and test utilities for WHOIS and date parsing logic
113 lines
3.0 KiB
Go
113 lines
3.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"regexp"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
testDomains := []string{"bookra.eu", "sportcreative.eu"}
|
|
|
|
for _, domain := range testDomains {
|
|
fmt.Printf("Testing EURid web scraping for: %s\n", domain)
|
|
fmt.Println("----------------------------------------")
|
|
|
|
// EURid web WHOIS URL
|
|
url := fmt.Sprintf("https://www.eurid.eu/en/registrations/search/?domain=%s", domain)
|
|
|
|
req, err := http.NewRequestWithContext(context.Background(), "GET", url, nil)
|
|
if err != nil {
|
|
fmt.Printf("Failed to create request: %v\n", err)
|
|
continue
|
|
}
|
|
|
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")
|
|
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
|
|
|
client := &http.Client{Timeout: 15 * time.Second}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Printf("Failed to fetch EURid web page: %v\n", err)
|
|
continue
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
if resp.StatusCode != 200 {
|
|
fmt.Printf("EURid web page returned status %d\n", resp.StatusCode)
|
|
continue
|
|
}
|
|
|
|
// Read the HTML response
|
|
body, err := io.ReadAll(resp.Body)
|
|
if err != nil {
|
|
fmt.Printf("Failed to read EURid response: %v\n", err)
|
|
continue
|
|
}
|
|
|
|
html := string(body)
|
|
fmt.Printf("HTML length: %d characters\n", len(html))
|
|
|
|
// Look for expiry date patterns
|
|
expiryPatterns := []string{
|
|
`Expiry date:\s*</strong>\s*(\d{2}/\d{2}/\d{4})`,
|
|
`Expiry date:</strong>\s*(\d{2}/\d{2}/\d{4})`,
|
|
`Expiry date</strong>\s*(\d{2}/\d{2}/\d{4})`,
|
|
`"expiryDate":"([^"]+)"`,
|
|
`data-expiry="([^"]+)"`,
|
|
`\d{2}/\d{2}/\d{4}`, // Generic date pattern
|
|
}
|
|
|
|
fmt.Println("\n=== Searching for expiry dates ===")
|
|
for _, pattern := range expiryPatterns {
|
|
re := regexp.MustCompile(pattern)
|
|
matches := re.FindAllStringSubmatch(html, -1)
|
|
if len(matches) > 0 {
|
|
fmt.Printf("Pattern '%s' found %d matches:\n", pattern, len(matches))
|
|
for i, match := range matches {
|
|
if len(match) > 1 {
|
|
fmt.Printf(" Match %d: %s\n", i+1, match[1])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Look for registrar patterns
|
|
registrarPatterns := []string{
|
|
`Registrar:\s*</strong>\s*([^<\n]+)`,
|
|
`Registrar:</strong>\s*([^<\n]+)`,
|
|
`Registrar</strong>\s*([^<\n]+)`,
|
|
`"registrar":"([^"]+)"`,
|
|
`data-registrar="([^"]+)"`,
|
|
}
|
|
|
|
fmt.Println("\n=== Searching for registrar ===")
|
|
for _, pattern := range registrarPatterns {
|
|
re := regexp.MustCompile(pattern)
|
|
matches := re.FindAllStringSubmatch(html, -1)
|
|
if len(matches) > 0 {
|
|
fmt.Printf("Pattern '%s' found %d matches:\n", pattern, len(matches))
|
|
for i, match := range matches {
|
|
if len(match) > 1 {
|
|
fmt.Printf(" Match %d: %s\n", i+1, strings.TrimSpace(match[1]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Show some sample HTML to understand the structure
|
|
fmt.Println("\n=== Sample HTML (first 1000 chars) ===")
|
|
if len(html) > 1000 {
|
|
fmt.Printf("%s...\n", html[:1000])
|
|
} else {
|
|
fmt.Printf("%s\n", html)
|
|
}
|
|
|
|
fmt.Println("\n========================================\n")
|
|
}
|
|
}
|