Compare commits
5 Commits
7b154e3a1d
...
4.0.2
Author | SHA1 | Date | |
---|---|---|---|
dce2c2dfa5 | |||
eaec1ba9d4 | |||
3059f785c2 | |||
279a9f2786 | |||
963f83ae81 |
@@ -55,7 +55,7 @@ def remove(index, number, args, basic, logger, ssl_wordpress):
|
|||||||
|
|
||||||
def download(name_thread, max_thread, url, logger, parser, directory, html, img, ssl_canalblog, revert, tmp):
|
def download(name_thread, max_thread, url, logger, parser, directory, html, img, ssl_canalblog, revert, tmp):
|
||||||
exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser, directory=directory, ssl_canalblog=ssl_canalblog)
|
exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser, directory=directory, ssl_canalblog=ssl_canalblog)
|
||||||
if not revert:
|
if revert is False:
|
||||||
exportWp.getUrlPage(name_thread, max_thread)
|
exportWp.getUrlPage(name_thread, max_thread)
|
||||||
for i in ["article", "page"]:
|
for i in ["article", "page"]:
|
||||||
for j in ["publications", "principal"]:
|
for j in ["publications", "principal"]:
|
||||||
@@ -170,7 +170,7 @@ if __name__ == '__main__':
|
|||||||
import_parser.add_argument("--no-create", help="No create post", dest="create", default="store_false", action="store_true")
|
import_parser.add_argument("--no-create", help="No create post", dest="create", default="store_false", action="store_true")
|
||||||
import_parser.add_argument("--no-update", help="No update post", dest="update", default="store_false", action="store_true")
|
import_parser.add_argument("--no-update", help="No update post", dest="update", default="store_false", action="store_true")
|
||||||
import_parser.add_argument("--no-image", help="No image add or update", dest="image", default="store_false", action="store_true")
|
import_parser.add_argument("--no-image", help="No image add or update", dest="image", default="store_false", action="store_true")
|
||||||
import_parser.add_argument("--author-album", dest="author", help="Define author for page album", default="")
|
import_parser.add_argument("--author", dest="author", help="Define author", default="")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -58,14 +58,26 @@ class WPExport:
|
|||||||
# Download HTML
|
# Download HTML
|
||||||
|
|
||||||
def downloadHTML(self, first, second):
|
def downloadHTML(self, first, second):
|
||||||
self._downloadPage(webpage[first][second], self._dir)
|
try:
|
||||||
|
with open("{0}/{1}.json".format(self._tmp, self._name)) as file:
|
||||||
|
webpage = json.loads(file.read())
|
||||||
|
self._downloadPage(webpage[first][second], self._dir)
|
||||||
|
except Exception as ex:
|
||||||
|
self._logger.error("{0} : Read file json from tmp : {1}".format(self._name, ex))
|
||||||
|
|
||||||
# Download Image
|
# Download Image
|
||||||
|
|
||||||
def downloadImg(self, first, second):
|
def downloadImg(self, first, second):
|
||||||
page_src = self._getImg(webpage[first][second])
|
try:
|
||||||
o = urlparse(self._url)
|
with open("{0}/{1}.json".format(self._tmp, self._name)) as file:
|
||||||
self._downloadPage(page_src, "{0}/{1}/{2}".format(self._dir, o.path, "img"))
|
webpage = json.loads(file.read())
|
||||||
|
page_src = self._getImg(webpage[first][second])
|
||||||
|
o = urlparse(self._url)
|
||||||
|
self._downloadPage(page_src, "{0}/{1}/{2}".format(self._dir, o.path, "img"))
|
||||||
|
except Exception as ex:
|
||||||
|
self._logger.error("{0} : Read file json from tmp : {1}".format(self._name, ex))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Get URL
|
# Get URL
|
||||||
|
@@ -237,7 +237,9 @@ class WPimport:
|
|||||||
break
|
break
|
||||||
author = self._getInfoAlbum(href_a)
|
author = self._getInfoAlbum(href_a)
|
||||||
self._logger.info("{0} : author : {1}".format(self._name, author))
|
self._logger.info("{0} : author : {1}".format(self._name, author))
|
||||||
self._getAuthor(author)
|
author = self._getAuthor(author)
|
||||||
|
data = {"title":albumtitle, "content":content_html, "status":"publish"}
|
||||||
|
|
||||||
if author != 0:
|
if author != 0:
|
||||||
data = {"title":albumtitle, "content":content_html, "status":"publish", "author":author}
|
data = {"title":albumtitle, "content":content_html, "status":"publish", "author":author}
|
||||||
self._logger.debug("{0} : data for album page : {1}".format(self._name, data))
|
self._logger.debug("{0} : data for album page : {1}".format(self._name, data))
|
||||||
@@ -849,7 +851,9 @@ class WPimport:
|
|||||||
self._logger.error("{0} : Exception error for post {1} : {2}".format(self._name, i, err))
|
self._logger.error("{0} : Exception error for post {1} : {2}".format(self._name, i, err))
|
||||||
|
|
||||||
title = articletitle[0].text
|
title = articletitle[0].text
|
||||||
author = articleacreator[0].text.lower()
|
author = articleacreator[0].text.lower()
|
||||||
|
if len(self._author) > 0:
|
||||||
|
author = self._author
|
||||||
body = articlebody[0].find_all("p")
|
body = articlebody[0].find_all("p")
|
||||||
bodyhtml = "<p>"
|
bodyhtml = "<p>"
|
||||||
for i in body:
|
for i in body:
|
||||||
|
Reference in New Issue
Block a user