From d10867a9837db6f37343296887e42ea276554b10 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 30 Jun 2023 23:28:54 +0200 Subject: [PATCH] add class WPMenu --- lib/WPMenu.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/WPMenu.py diff --git a/lib/WPMenu.py b/lib/WPMenu.py new file mode 100644 index 0000000..cfa2f28 --- /dev/null +++ b/lib/WPMenu.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +from bs4 import BeautifulSoup +from urllib.parse import urlparse +import requests, os, logging, re, json +from requests.adapters import HTTPAdapter +from requests.packages.urllib3.util.retry import Retry + +class WPMenu: + # Constructor + def __init__(self, name="Thread-0", basic=None, wordpress="", logger=None, parser="html.parser", ssl_wordpress=True): + self._name = name + self._basic = basic + self._wordpress = wordpress + self._logger = logger + self._parser = parser + self._headers_json = {'Content-Type': 'application/json; charset=utf-8', 'Accept':'application/json'} + self._protocol = "https" + self._directory = "backup" + if ssl_wordpress is False: + self._protocol = "http" + self._request = requests.Session() + + retries = Retry(connect=10, read=10, redirect=5, + status_forcelist=[429, 500, 502, 503, 504], backoff_factor=2) + + self._request.mount('{0}://'.format(self._protocol), HTTPAdapter(max_retries=retries)) + + # Destructor + def __del__(self): + print("{0} : Import finished for {1}".format(self._name, self._wordpress)) \ No newline at end of file