The GoogleSafeBrowsing class provides an interface to Google’s Safe Browsing API (v4) for checking Links against known threat lists. It handles API communication, payload construction, and response processing.
📑 Class Attributes
Attribute
Type
Description
URL
str
Endpoint URL constructed from settings.GOOGLE_SAFEBROWSING_BASE_URL
API_KEY
str
API key loaded from settings.GOOGLE_SAFEBROWSING_API_KEY
🧩 Methods
Method
Description
_build_payload(links)
Constructs the API request payload from a list of links.
_send_request(links)
Sends the request to the Google Safe Browsing API and returns the response.
check_links(links)
Public method to check a list of links/domains against the Google Safe Browsing API.
📍 Where Using
Block links tasks - checks links and blocks them if they are found in Google Safe Browsing lists.
Unblock links tasks - unblocks links that were previously blocked by Google Safe Browsing.