diff --git a/import_export_canalblog.py b/import_export_canalblog.py index 6e1e510..8a35d24 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -9,10 +9,10 @@ from lib.WPImport import WPimport from lib.WPExport import WPExport -def download(name_thread, max_thread, exportWp, html, img): +def download(name_thread, max_thread, url, logger, parser, directory, html, img): #def download(args): - + exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser, directory=directory) webpage = exportWp.getUrlPage(name_thread, max_thread) if html is False: @@ -151,7 +151,7 @@ if __name__ == '__main__': if args.command == "export": canalblog = args.url.split(",") - exportWp = WPExport("", logger, args.parser, args.directory) + exportWp = WPExport(logger=logger, parser=args.parser, directory=args.directory) for canal in canalblog: try: o = urlparse(canal) @@ -173,7 +173,7 @@ if __name__ == '__main__': #f = ex.map(download, args) #print("wait !!!") wait_for = [ - ex.submit(download, i, int(args.parallel), exportWp, args.html, args.img) + ex.submit(download, i, int(args.parallel), url, logger, args.parser, args.directory, args.html, args.img) for i in range(0, int(args.parallel)) ] diff --git a/lib/WPExport.py b/lib/WPExport.py index b6e7800..957a234 100644 --- a/lib/WPExport.py +++ b/lib/WPExport.py @@ -6,12 +6,12 @@ from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry class WPExport: - def __init__(self, url, logger, parser, directory): + def __init__(self, name = "Thread-0", url = "", logger = None, parser = "html.parser", directory = "backup"): self._url = url self._logger = logger self._parser = parser self._dir = directory - self._name = "Thread-0" + self._name = name self._request = requests.Session() @@ -62,7 +62,6 @@ class WPExport: # Get URL def getUrlPage(self, index_thread, max_thread): - self._name = "Thread-{0}".format(index_thread + 1) try: page = self._request.get(self._url) except Exception as err: