From cd2fbd5372186aba2fdf018282a2d2285a80c676 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 25 May 2023 00:31:34 +0200 Subject: [PATCH] add protocol https/http --- import_export_canalblog.py | 62 +++++++++++++++++++++++--------------- lib/WPExport.py | 10 +++--- lib/WPImport.py | 46 ++++++++++++++-------------- lib/WPRemove.py | 13 +++++--- 4 files changed, 76 insertions(+), 55 deletions(-) diff --git a/import_export_canalblog.py b/import_export_canalblog.py index 6a2a3e3..defac75 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -10,8 +10,8 @@ from lib.WPImport import WPimport from lib.WPExport import WPExport from lib.WPRemove import WPRemove -def remove(args, basic, logger): - removeWp = WPRemove(basic=basic, wordpress="", logger=logger) +def remove(args, basic, logger, ssl_wordpress): + removeWp = WPRemove(basic=basic, wordpress="", logger=logger, ssl_wordpress=ssl_wordpress) if args.remove == True: for i in args.wordpress.split(","): removeWp.setUrl(i) @@ -33,8 +33,8 @@ def remove(args, basic, logger): del removeWp -def download(name_thread, max_thread, url, logger, parser, directory, html, img): - exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser, directory=directory) +def download(name_thread, max_thread, url, logger, parser, directory, html, img, ssl_canalblog): + exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser, directory=directory, ssl_canalblog=ssl_canalblog) webpage = exportWp.getUrlPage(name_thread, max_thread) for i in ["article", "page"]: for j in ["publications", "principal"]: @@ -47,25 +47,27 @@ def download(name_thread, max_thread, url, logger, parser, directory, html, img) -def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, basic, serial): +def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, basic, serial, ssl_wordpress, ssl_canalblog): canalblog = canalblog.split(",") wordpress = wordpress.split(",") name = "Thread-{0}".format(int(name_thread) + 1) - + protocol = "https" + if ssl_canalblog is False: + protocol = "http" if serial is False: for canal in canalblog: try: o = urlparse(canal) - o = o._replace(scheme="https") + o = o._replace(scheme=protocol) url = o.geturl().replace(":///", "://") except Exception as err: logger.error("{0} : parsing error : {1}".format(name, err)) exit(1) - exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser) + exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser, ssl_canalblog=ssl_canalblog) webpage = exportWp.getUrlPage(name_thread, max_thread) del exportWp for j in wordpress: - importWp = WPimport(name=name, basic=basic, wordpress=j, logger=logger, parser=parser) + importWp = WPimport(name=name, basic=basic, wordpress=j, logger=logger, parser=parser, ssl_wordpress=ssl_wordpress) for k in ["article", "page"]: for l in ["publications", "principal"]: importWp.fromUrl(webpage[l][k]) @@ -78,15 +80,15 @@ def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, bas for i in range(0, len(canalblog)-1): try: o = urlparse(canalblog[i]) - o = o._replace(scheme="https") + o = o._replace(scheme=protocol) url = o.geturl().replace(":///", "://") except Exception as err: logger.error("parsing error : {0}".format(err)) exit(1) - exportWp = WPExport(name=name, url=url, logger=logger, parser=parser) + exportWp = WPExport(name=name, url=url, logger=logger, parser=parser, ssl_canalblog=ssl_canalblog) webpage = exportWp.getUrlPage(name_thread, max_thread) del exportWp - importWp = WPimport(name=name, basic=basic, wordpress=wordpress[i], logger=logger, parser=parser) + importWp = WPimport(name=name, basic=basic, wordpress=wordpress[i], logger=logger, parser=parser, ssl_wordpress=ssl_wordpress) for k in ["article", "page"]: for l in ["publications", "principal"]: @@ -95,13 +97,13 @@ def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, bas del importWp -def importDirectory(name_thread, max_thread, directory, logger, parser, wordpress, basic, serial): +def importDirectory(name_thread, max_thread, directory, logger, parser, wordpress, basic, serial, ssl_wordpress): name = "Thread-{0}".format(int(name_thread) + 1) directory = directory.split(",") wordpress = wordpress.split(",") if serial is False: for i in wordpress: - importWp = WPimport(name=name, basic=basic, wordpress=i, logger=logger, parser=parser) + importWp = WPimport(name=name, basic=basic, wordpress=i, logger=logger, parser=parser, ssl_wordpress=ssl_wordpress) for j in directory: importWp.fromDirectory(j, name_thread, max_thread) del importWp @@ -111,7 +113,7 @@ def importDirectory(name_thread, max_thread, directory, logger, parser, wordpres logger.error("{0} : Error : Number directory is differant than wordpress".format(name)) exit(1) for i in range(0, len(wordpress)-1): - importWp = WPimport(name=name, basic=basic, wordpress=wordpress[i], logger=logger, parser=parser) + importWp = WPimport(name=name, basic=basic, wordpress=wordpress[i], logger=logger, parser=parser, ssl_wordpress=ssl_wordpress) importWp.fromDirectory(directory[i]) del importWp @@ -124,6 +126,7 @@ if __name__ == '__main__': parser.add_argument("--quiet", help="No console output", action="store_true") parser.add_argument("--parser", help="Parser content", default="html.parser") parser.add_argument("--parallel", help="Define number thread (default : 1)", default=1) + parser.add_argument("--no-ssl", help="No ssl for canalblog and/or wordpress (example wordpress,canalblog)", dest=ssl, default="") subparsers = parser.add_subparsers(dest="command") @@ -171,6 +174,14 @@ if __name__ == '__main__': logger = logging.getLogger('import export canalblog') formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + ssl_canalblog = True + ssl_wordpress = True + + for i in args.ssl.split(","): + if i == "canalblog": + ssl_canalblog = False + if i == "wordpress": + ssl_wordpress = False if args.quiet is False: ch = logging.StreamHandler() @@ -204,27 +215,27 @@ if __name__ == '__main__': basic = HTTPBasicAuth(args.user, password) if args.command == "import": wordpress = args.wordpress.split(",") - importWp = WPimport(basic=basic, wordpress="", logger=logger, parser=args.parser) + importWp = WPimport(basic=basic, wordpress="", logger=logger, parser=args.parser, ssl_wordpress=ssl_wordpress) if len(args.file) > 0: for i in wordpress: importWp.setUrl(i) importWp.fromFile(files=args.file.split(",")) if len(args.directory) > 0: - remove(args, basic, logger) + remove(args, basic, logger, ssl_wordpress) try: with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex: wait_for = [ - ex.submit(importDirectory, i, int(args.parallel), args.directory, logger, args.parser, args.wordpress, basic, args.serial) + ex.submit(importDirectory, i, int(args.parallel), args.directory, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress) for i in range(0, int(args.parallel)) ] except Exception as err: logger.error("Threading error : {0}".format(err)) if len(args.canalblog) > 0: - remove(args, basic, logger) + remove(args, basic, logger, ssl_wordpress) try: with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex: wait_for = [ - ex.submit(importUrl, i, int(args.parallel), args.canalblog, logger, args.parser, args.wordpress, basic, args.serial) + ex.submit(importUrl, i, int(args.parallel), args.canalblog, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress, ssl_canalblog) for i in range(0, int(args.parallel)) ] except Exception as err: @@ -234,11 +245,14 @@ if __name__ == '__main__': if args.command == "export": canalblog = args.url.split(",") - exportWp = WPExport(logger=logger, parser=args.parser, directory=args.directory) + protocol = "https" + if ssl_canalblog is False: + protocol = "http" + exportWp = WPExport(logger=logger, parser=args.parser, directory=args.directory, ssl_canalblog=ssl_canalblog) for canal in canalblog: try: o = urlparse(canal) - o = o._replace(scheme="https") + o = o._replace(scheme=protocol) url = o.geturl().replace(":///", "://") except Exception as err: logger.error("parsing error : {0}".format(err)) @@ -257,7 +271,7 @@ if __name__ == '__main__': try: with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex: wait_for = [ - ex.submit(download, i, int(args.parallel), url, logger, args.parser, args.directory, args.html, args.img) + ex.submit(download, i, int(args.parallel), url, logger, args.parser, args.directory, args.html, args.img, ssl_canalblog) for i in range(0, int(args.parallel)) ] except Exception as err: @@ -266,5 +280,5 @@ if __name__ == '__main__': if args.command == "remove": - remove(args, basic, logger) + remove(args, basic, logger, ssl_wordpress) exit(0) \ No newline at end of file diff --git a/lib/WPExport.py b/lib/WPExport.py index 90080b7..8ff0100 100644 --- a/lib/WPExport.py +++ b/lib/WPExport.py @@ -6,20 +6,22 @@ from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry class WPExport: - def __init__(self, name = "Thread-0", url = "", logger = None, parser = "html.parser", directory = "backup"): + def __init__(self, name = "Thread-0", url = "", logger = None, parser = "html.parser", directory = "backup", ssl_canalblog=True): self._url = url self._logger = logger self._parser = parser self._dir = directory self._name = name - + self._protocol = "https" + if ssl_canalblog is False: + self._protocol = "http" self._request = requests.Session() retries = Retry(total=10, status_forcelist=[429, 500, 502, 503, 504], backoff_factor=2) - self._request.mount('http://', HTTPAdapter(max_retries=retries)) + self._request.mount('{0}://'.format(self._protocol), HTTPAdapter(max_retries=retries)) # Destructor @@ -89,7 +91,7 @@ class WPExport: for i in page_url: section = "publications" o = urlparse(i) - o = o._replace(scheme="https") + o = o._replace(scheme=self._protocol) i = o.geturl().replace(":///", "://") if i == "{0}/".format(self._url): section = "principal" diff --git a/lib/WPImport.py b/lib/WPImport.py index 8d7cbc6..3f343cc 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -8,20 +8,22 @@ from requests.packages.urllib3.util.retry import Retry class WPimport: # Constructor - def __init__(self, name="Thread-0", basic=None, wordpress="", logger=None, parser="html.parser"): + 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" + 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('http://', HTTPAdapter(max_retries=retries)) + self._request.mount('{0}://'.format(self._protocol), HTTPAdapter(max_retries=retries)) # Destructor @@ -134,7 +136,7 @@ class WPimport: h2 = i.find_all("h2")[0].text params = {"search":h2, "type":"post"} try: - page = self._request.get("http://{0}/wp-json/wp/v2/search".format(self._wordpress), auth=self._basic, params=params) + page = self._request.get("{1}://{0}/wp-json/wp/v2/search".format(self._wordpress, self._protocol), auth=self._basic, params=params) except Exception as err: self._logger.error("{0} : Connection error : {1}".format(self._name, err)) exit(1) @@ -155,7 +157,7 @@ class WPimport: name_img = name_img.split("/")[len(name_img.split("/"))-1] params = {"search": name_img} try: - page = self._request.get("http://{0}/wp-json/wp/v2/media".format(self._wordpress), auth=self._basic, params=params) + page = self._request.get("{1}://{0}/wp-json/wp/v2/media".format(self._wordpress, self._protocol), auth=self._basic, params=params) except Exception as err: self._logger.error("{0} : Connection error search featured media : {1}".format(self._name, err)) exit(1) @@ -165,7 +167,7 @@ class WPimport: id_media = res[0]["id"] data = {"featured_media": id_media} try: - r = self._request.post("http://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, result[0]["id"]), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) + r = self._request.post("{2}://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, result[0]["id"], self._protocol), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) except Exception as err: self._logger.error("{0} : Connection error for post media featured : {1}".format(self._name, err)) exit(1) @@ -196,7 +198,7 @@ class WPimport: for i in list_img: data = {"post": post_id} try: - r = self._request.post("http://{0}/wp-json/wp/v2/media/{1}".format(self._wordpress, i["id"]), auth=self._basic, data=data) + r = self._request.post("{2}://{0}/wp-json/wp/v2/media/{1}".format(self._wordpress, i["id"], self._protocol), auth=self._basic, data=data) except Exception as err: self._logger.error("{0} : Connection error for link image to post : {1}".format(self._name, err)) exit(1) @@ -220,10 +222,10 @@ class WPimport: self._logger.error("{0} : Element {1} is not image".format(self._name,img_name)) is_img = False if is_img is True: - self._logger.debug("{0} : Search for image {1} with URL {2}".format(self._name, img_name, "http://{0}/wp-json/wp/v2/media".format(self._wordpress))) + self._logger.debug("{0} : Search for image {1} with URL {2}".format(self._name, img_name, "{1}://{0}/wp-json/wp/v2/media".format(self._wordpress, self._protocol))) params = { "search": img_name} try: - r = self._request.get("http://{0}/wp-json/wp/v2/media".format(self._wordpress), auth=self._basic, params=params) + r = self._request.get("{1}://{0}/wp-json/wp/v2/media".format(self._wordpress, self._protocol), auth=self._basic, params=params) except Exception as err: self._logger.error("{0} : Connection error for search media : {1}".format(self._name, err)) exit(1) @@ -234,7 +236,7 @@ class WPimport: if len(res) > 0: params = {"force":1} try: - r = self._request.delete("http://{0}/wp-json/wp/v2/media/{1}".format(self._wordpress, res[0]["id"]), auth=self._basic, params=params) + r = self._request.delete("{2}://{0}/wp-json/wp/v2/media/{1}".format(self._wordpress, res[0]["id"], self._protocol), auth=self._basic, params=params) except Exception as err: self._logger.error("{0} Connection error for delete image : {1}".format(self._name, err)) exit(1) @@ -250,7 +252,7 @@ class WPimport: img_type = "image/jpeg" headers={ 'Content-Type': img_type,'Content-Disposition' : 'attachment; filename={0}'.format(img_name)} try: - r = self._request.post("http://{0}/wp-json/wp/v2/media".format(self._wordpress), auth=self._basic, headers=headers, data=data) + r = self._request.post("{1}://{0}/wp-json/wp/v2/media".format(self._wordpress, self._protocol), auth=self._basic, headers=headers, data=data) except Exception as err: self._logger.error("{0} : Connection error for add image : {1}".format(self._name, err)) exit(1) @@ -276,7 +278,7 @@ class WPimport: try: params = {"post": post, "author_name":i["author"], "date":i["date"]} - page = self._request.get("http://{0}/wp-json/wp/v2/comments".format(self._wordpress), auth=self._basic, params=params) + page = self._request.get("{1}://{0}/wp-json/wp/v2/comments".format(self._wordpress, self._protocol), auth=self._basic, params=params) except Exception as err: self._logger.error("{0} : Connection error for search comment : {1}".format(self._name, err)) exit(1) @@ -285,7 +287,7 @@ class WPimport: for j in result: try: params = {"force":1} - page = self._request.delete("http://{0}/wp-json/wp/v2/comments/{1}".format(self._wordpress, j["id"]), params=params, auth=self._basic) + page = self._request.delete("{2}://{0}/wp-json/wp/v2/comments/{1}".format(self._wordpress, j["id"], self._protocol), params=params, auth=self._basic) except Exception as err: self._logger.error("{0} : Connection error for delete comment : {1}".format(self._name, err)) exit(1) @@ -307,7 +309,7 @@ class WPimport: parent_id = int(i["parent_id"]) params = {"post": post, "author_name":comment[parent_id]["author"], "date":comment[parent_id]["date"]} try: - page = self._request.get("http://{0}/wp-json/wp/v2/comments".format(self._wordpress), auth=self._basic, params=params) + page = self._request.get("{1}://{0}/wp-json/wp/v2/comments".format(self._wordpress, self._protocol), auth=self._basic, params=params) except Exception as err: self._logger.error("{0} : Connection error for parent comment : {1}".format(self._name, err)) exit(1) @@ -320,7 +322,7 @@ class WPimport: self._logger.debug("{0} : {1}".format(self._name, page.content)) try: - page = self._request.post("http://{0}/wp-json/wp/v2/comments".format(self._wordpress), auth=self._basic, data=data) + page = self._request.post("{1}://{0}/wp-json/wp/v2/comments".format(self._wordpress, self._protocol), auth=self._basic, data=data) except Exception as err: self._logger.error("{0} : Connection error for add comment : {1}".format(self._name, err)) exit(1) @@ -459,7 +461,7 @@ class WPimport: self._logger.info("{0} : search {1} with index {2} : {3}".format(self._name, i, index, title_element)) try: params = {"search":title_element, "per_page":"100", "page":index} - page = self._request.get("http://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i), auth=self._basic, params=params) + page = self._request.get("{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol), auth=self._basic, params=params) except ConnectionError as err: self._logger.error("{0} : Connection error for {1} : {2}".format(self._name, i, err)) exit(1) @@ -496,7 +498,7 @@ class WPimport: self._logger.info("{0} : Create {1} : {2}".format(self._name, i, title_element)) self._logger.debug("{0} : Data : {1}".format(self._name, data)) try: - page = self._request.post("http://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) + page = self._request.post("{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) except ConnectionError as err: self._logger.error("{0} : Connection error for post {1} : {2}".format(self._name, i, err)) exit(1) @@ -536,7 +538,7 @@ class WPimport: params = {"search":author, "per_page":100} try: self._logger.info("{0} : Search author : {1}".format(self._name, author)) - page = self._request.get("http://{0}/wp-json/wp/v2/users".format(self._wordpress), auth=self._basic, headers=self._headers_json, params=params) + page = self._request.get("{1}://{0}/wp-json/wp/v2/users".format(self._wordpress, self._protocol), auth=self._basic, headers=self._headers_json, params=params) self._logger.debug("{0} : End Search author : {1}".format(self._name, author)) self._logger.debug("{0} : Debug requests : {1}".format(self._name, page.content)) @@ -560,7 +562,7 @@ class WPimport: params = {"search": title, "per_page":100, "page": index} try: self._logger.info("{0} : Search post with index {2} : {1}".format(self._name, title, index)) - page = self._request.get("http://{0}/wp-json/wp/v2/posts".format(self._wordpress), auth=self._basic, params=params, headers=self._headers_json) + page = self._request.get("{1}://{0}/wp-json/wp/v2/posts".format(self._wordpress, self._protocol), auth=self._basic, params=params, headers=self._headers_json) except ConnectionError as err: self._logger.error("{0} : Connection error for search post : {1}".format(self._name, err)) exit(1) @@ -589,7 +591,7 @@ class WPimport: self._logger.info("{0} : Page {1} is double and going to delete".format(self._name, title)) try: params = {"force":1} - page = self._request.delete("http://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, post_id), auth=self._basic, headers=self._headers_json, params=params) + page = self._request.delete("{2}://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, post_id, self._protocol), auth=self._basic, headers=self._headers_json, params=params) except ConnectionError as err: self._logger.error("{0} : Connection error for deleted post : {1}".format(self._name, err)) exit(1) @@ -606,7 +608,7 @@ class WPimport: self._logger.info("{0} : Page {1} already exist and going to update".format(self._name, title)) try: - page = self._request.post("http://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, post_id), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) + page = self._request.post("{2}://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, post_id, self._protocol), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) except ConnectionError as err: self._logger.error("{0} : Connection error for update post : {1}".format(self._name, err)) exit(1) @@ -631,7 +633,7 @@ class WPimport: if page_is_exist is False: try: self._logger.info("{0} : Creating posts : {1}".format(self._name, data["title"])) - page = self._request.post("http://{0}/wp-json/wp/v2/posts".format(self._wordpress), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) + page = self._request.post("{1}://{0}/wp-json/wp/v2/posts".format(self._wordpress, self._protocol), auth=self._basic, headers=self._headers_json, data=json.dumps(data)) except ConnectionError as err: self._logger.error("{0} : Connection error for create post : {1}".format(self._name, err)) exit(1) diff --git a/lib/WPRemove.py b/lib/WPRemove.py index ad4ab8a..8d38ca7 100644 --- a/lib/WPRemove.py +++ b/lib/WPRemove.py @@ -8,19 +8,22 @@ from requests.packages.urllib3.util.retry import Retry class WPRemove: # Constructor - def __init__(self, name="Thread-0", basic=None, wordpress="", logger=None): + def __init__(self, name="Thread-0", basic=None, wordpress="", logger=None, ssl_wordpress=True): self._name = name self._basic = basic self._wordpress = wordpress self._logger = logger self._headers_json = {'Content-Type': 'application/json', 'Accept':'application/json'} - + + self._protocol = "https" + 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('http://', HTTPAdapter(max_retries=retries)) + self._request.mount('{0}://'.format(self._protocol), HTTPAdapter(max_retries=retries)) # Destructor @@ -51,7 +54,7 @@ class WPRemove: try: self._logger.info("{0} : List {2} to remove for url : {1}".format(self._name, self._wordpress, composant)) - r = self._request.get("http://{0}/wp-json/wp/v2/{1}".format(self._wordpress, composant), auth=self._basic, params=params, headers=self._headers_json) + r = self._request.get("{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, composant, self._protocol), auth=self._basic, params=params, headers=self._headers_json) except Exception as err: self._logger.error("{0} : Connection error for list {1} to remove : {2}".format(self._name, composant, err)) if r.status_code == 200: @@ -61,7 +64,7 @@ class WPRemove: self._logger.info("{0} : Remove {2} for url {1} : {3}".format(self._name, self._wordpress, composant, i["title"]["rendered"])) params = {"force":1} try: - r = self._request.delete("http://{0}/wp-json/wp/v2/{1}/{2}".format(self._wordpress, composant, i["id"]), auth=self._basic, headers=self._headers_json , params=params) + r = self._request.delete("{3}://{0}/wp-json/wp/v2/{1}/{2}".format(self._wordpress, composant, i["id"], self._protocol), auth=self._basic, headers=self._headers_json , params=params) if r.status_code == 200: self._logger.info("{0} : Post removed for URL {1} {2} : {3}".format(self._name, self._wordpress, composant, i["title"]["rendered"])) else: