From e0b4895b62072edd65da8aa560e9d59cca55c342 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 31 Mar 2023 00:14:38 +0200 Subject: [PATCH] association image article --- insert_wordpress.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/insert_wordpress.py b/insert_wordpress.py index 9e40faa..0f1b2fa 100644 --- a/insert_wordpress.py +++ b/insert_wordpress.py @@ -162,6 +162,12 @@ class WPimport: page = requests.post("http://{0}/wp-json/wp/v2/comments".format(self.wordpress), auth=self.basic, data=data) if page.status_code == 201: print("Commentaire ajoute pour {0}".format(result["title"]["raw"])) + for i in list_img: + data = {"post": result["id"]} + r = requests.post("http://{0}/wp-json/wp/v2/media/{1}".format(self.wordpress, i["id"]), auth=self.basic, data=data) + if r.status_code == 200: + print("Association d'une image à l'article {0}".format(result["title"]["raw"])) +