我正在尝试从包含域(未知数量)的文本文件中获取输入,然后将每个域用作参数并获取其服务器类型。正如预期的那样,这只会返回最后一个域。如何迭代多个返回值?下面是代码。// 测试包主
import (
"bufio"
"time"
"os"
"fmt"
"net/http"
//"github.com/gocolly/colly"
)
var Domain string
var Target string
func main() {
Domain := DomainGrab()
Target := BannerGrab(Domain)
//CheckDB if not listed then add else skip
//RiskDB
fmt.Println(Domain)
fmt.Println(Target)
}
func BannerGrab(s string) string {
client := &http.Client{}
req, err := http.NewRequest("GET", s, nil)
if err != nil {
log.Fatalln(err)
}
req.Header.Set("User-Agent", "Authac/0.1")
resp, _ := client.Do(req)
serverEntry := resp.Header.Get("Server")
return serverEntry
}
func DomainGrab() string {
//c := colly.NewCollector()
// Open the file.
f, _ := os.Open("domains.txt")
defer f.Close()
// Create a new Scanner for the file.
scanner := bufio.NewScanner(f)
// Loop over all lines in the file and print them.
for scanner.Scan() {
line := scanner.Text()
time.Sleep(2 * time.Second)
//fmt.Println(line)
return line
}
return Domain
}
肥皂起泡泡
RISEBY
隔江千里
相关分类