complexorganizations / content-blocker

✔️ Content Blocker is a robust web filtering project aimed at enhancing online privacy and security.
Other
16 stars 1 forks source link

Virus total api #73

Closed ghost closed 3 years ago

ghost commented 3 years ago

Note: Do not push this code to production.

func main() {
    domainCatogory("google.com", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
}

func domainCatogory(url string, apiKey string) bool {
    response, err := http.Get(fmt.Sprint("https://www.virustotal.com/vtapi/v2/domain/report?apikey=" + apiKey + "&domain=" + url))
    if err != nil {
        log.Println(err)
    }
    body, err := io.ReadAll(response.Body)
    if err != nil {
        log.Println(err)
    }
    if response.StatusCode == 200 {
        if strings.Contains(string(body), "Ads/Analytics") || strings.Contains(string(body), "advertisements") || strings.Contains(string(body), "web analytics") {
            return true
        }
        defer response.Body.Close()
    } else {
        time.Sleep(60 * time.Second)
    }
    return false
}
ghost commented 3 years ago

Note: The api has a limit for 4 per min.