Files
matitos_news/app_urls/api/obsolete_src/google_bypass.py
2025-03-12 17:56:40 +01:00

27 lines
851 B
Python

import requests
import json
from .logger import get_logger
logger = get_logger()
class GoogleByPass():
def __init__(self) -> None:
pass
def bypass_google_urls(self, list_urls):
if (len(list_urls) == 0):
return []
try:
# Endpoint
gbypass_endpoint = "http://selenium_app:80/get_redirection"
# Timeout: 20 minutes
timeout = 60*20
r = requests.post(gbypass_endpoint, json={"list_urls": list_urls}, timeout=timeout)
# Decode
list_urls_redirections = json.loads(r.text).get("list_urls_redirections", [])
except Exception as e:
logger.warning("Exception on request: {}. {}".format(gbypass_endpoint, str(e)))
list_urls_redirections = []
return list_urls_redirections