update post

This commit is contained in:
Valentin CZERYBA 2023-04-01 00:18:56 +02:00
parent bcb3abce01
commit faa22f1438

View File

@ -150,7 +150,14 @@ class WPimport:
if len(result) == 0:
page_exist = False
else:
print("La page {0} existe deja".format(title))
print("La page {0} existe deja et mis à jour".format(title))
post_id = result[0]["id"]
page = requests.post("http://{0}/wp-json/wp/v2/posts/{1}".format(self.wordpress, post_id), auth=self.basic, data=data)
if page.status_code == 200:
result = page.json()
print("Article mis à jour : {0}".format(result["title"]["raw"]))
if page_exist == False:
page = requests.post("http://{0}/wp-json/wp/v2/posts".format(self.wordpress), auth=self.basic, data=data)