Compare commits
1 Commits
6f78a48e57
...
4.0.2
Author | SHA1 | Date | |
---|---|---|---|
dce2c2dfa5 |
@@ -141,7 +141,7 @@ class WPimport:
|
||||
|
||||
def _getInfoAlbum(self, link):
|
||||
if self._ssl_canalblog:
|
||||
link = link.replace("http", "https").("httpss", "https")
|
||||
link = link.replace("http", "https")
|
||||
self._logger.info("{0} : Info album : {1}".format(self._name, link))
|
||||
link_o = urlparse(link)
|
||||
if len(link_o.netloc) > 0:
|
||||
@@ -162,15 +162,13 @@ class WPimport:
|
||||
if os.path.exists("{0}/..{1}".format(self._directory, link_o)):
|
||||
page_img = open("{0}/..{1}".format(self._directory, link_o), "r")
|
||||
soup = BeautifulSoup(page_img, self._parser)
|
||||
paragraphs = soup.find("div", class_="albumbody").find_all("p")
|
||||
for paragraph in paragraphs:
|
||||
paragraph = soup.find("div", class_="albumbody").find("p")
|
||||
self._logger.info("{0} get paragraph : {1}".format(self._name, paragraph))
|
||||
split_paragraph = str(paragraph).split("<br>")
|
||||
self._logger.info("{0} length paragraph splitted : {1}".format(self._name, len(split_paragraph)))
|
||||
if len(split_paragraph) == 1:
|
||||
split_paragraph = str(paragraph).split("<br/>")
|
||||
self._logger.info("{0} get paragraph splitted : {1}".format(self._name, split_paragraph))
|
||||
if len(split_paragraph) > 1:
|
||||
author = split_paragraph[1].split(":")[1].replace(" ", "").lower()
|
||||
return author
|
||||
|
||||
@@ -304,7 +302,7 @@ class WPimport:
|
||||
exit(1)
|
||||
except Exception as err:
|
||||
self._logger.error("{0} : Exception error for update page : {1}".format(self._name, err))
|
||||
elif page.status_code == 400:
|
||||
if page.status_code == 400:
|
||||
self._logger.error("{0} : Connection for update post unauthorized : {1}".format(self._name, page.status_code))
|
||||
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||
break
|
||||
@@ -819,7 +817,7 @@ class WPimport:
|
||||
listelement[i].append(k["id"])
|
||||
else:
|
||||
break
|
||||
elif page.status_code == 400:
|
||||
if page.status_code == 400:
|
||||
self._logger.error("{0} : {1} not found due status code : {2}".format(self._name, i, page.status_code))
|
||||
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||
break
|
||||
@@ -869,14 +867,11 @@ class WPimport:
|
||||
bodyhtml = bodyhtml.replace(i["old_href"], o.path)
|
||||
bodyhtml = bodyhtml.replace(i["old_src"], o.path)
|
||||
hour = articledate[0].text
|
||||
time = ""
|
||||
if len(dateheader) > 0:
|
||||
time = dateheader[0].text.split(" ")
|
||||
self._logger.debug("{0} : Title post : |{1}|".format(self._name, title))
|
||||
title = self._removeSpace(title)
|
||||
self._logger.debug("{0} : Rendered Title post : |{1}|".format(self._name, title))
|
||||
data = {"title":title, "content":bodyhtml, "status":"publish", "tags": listelement["tags"], "categories": listelement["categories"]}
|
||||
if len(dateheader) > 0:
|
||||
|
||||
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"]}
|
||||
self._logger.debug("{0} : Data for post : |{1}| : {2}" .format(self._name, title, data))
|
||||
|
||||
|
Reference in New Issue
Block a user