fix add author
This commit is contained in:
parent
82ce3d1a2b
commit
e3b9e92c23
@ -69,15 +69,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
|
|
||||||
title = articletitle[0].text
|
title = articletitle[0].text
|
||||||
author = articleacreator[0].text.lower()
|
author = articleacreator[0].text.lower()
|
||||||
author_exist = False
|
|
||||||
params = {"search":author}
|
|
||||||
page = requests.get("http://localhost:8080/wp-json/wp/v2/users", auth=basic, params=params)
|
|
||||||
if page.status_code == 200:
|
|
||||||
result = page.json()
|
|
||||||
print(result)
|
|
||||||
author_id = result[0]["id"]
|
|
||||||
author_exist = True
|
|
||||||
body = articlebody[0].find_all("p")
|
body = articlebody[0].find_all("p")
|
||||||
bodyhtml = "<p>"
|
bodyhtml = "<p>"
|
||||||
for i in body:
|
for i in body:
|
||||||
@ -88,9 +80,14 @@ if __name__ == '__main__':
|
|||||||
bodyhtml = bodyhtml + "</p>"
|
bodyhtml = bodyhtml + "</p>"
|
||||||
hour = articledate[0].text
|
hour = articledate[0].text
|
||||||
time = dateheader[0].text.split(" ")
|
time = dateheader[0].text.split(" ")
|
||||||
|
|
||||||
data = {"title":title, "content":bodyhtml, "status":"publish", "date": "{0}-{1}-{2}T{3}:00".format(time[2],month[time[1]],time[0], hour), "tags": listelement["tags"], "categories": listelement["categories"]}
|
data = {"title":title, "content":bodyhtml, "status":"publish", "date": "{0}-{1}-{2}T{3}:00".format(time[2],month[time[1]],time[0], hour), "tags": listelement["tags"], "categories": listelement["categories"]}
|
||||||
if author_exist == True:
|
params = {"search":author}
|
||||||
data["author"] = author_id
|
page = requests.get("http://localhost:8080/wp-json/wp/v2/users", auth=basic, params=params)
|
||||||
|
if page.status_code == 200:
|
||||||
|
result = page.json()
|
||||||
|
data["author"] = result[0]["id"]
|
||||||
|
|
||||||
|
|
||||||
params = {"search":title}
|
params = {"search":title}
|
||||||
page = requests.get("http://localhost:8080/wp-json/wp/v2/posts", auth=basic, params=params)
|
page = requests.get("http://localhost:8080/wp-json/wp/v2/posts", auth=basic, params=params)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user