From aa5c8893ec8051344ea5d5fa162bf99115e93299 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 10 Apr 2023 16:02:40 +0200 Subject: [PATCH] loop for url --- import_export_canalblog.py | 56 +++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/import_export_canalblog.py b/import_export_canalblog.py index 96314ec..817c905 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -76,38 +76,44 @@ if __name__ == '__main__': importWp.fromDirectory(args.directory) exit(0) if len(args.canalblog) > 0: + exportWp = WPExport.WPExport("", logger, args.parser, args.directory) + canalblog = args.canalblog.split(",") + for canal in canalblog: + try: + o = urlparse(canal) + o = o._replace(scheme="https") + url = o.geturl().replace(":///", "://") + except Exception as err: + logger.error("parsing error : {0}".format(err)) + exit(1) + exportWp.setUrl(url) + webpage = exportWp.getUrlPage() + importWp.fromUrl(webpage) + + + if args.command == "export": + canalblog = args.url.split(",") + exportWp = WPExport.WPExport("", logger, args.parser, args.directory) + for canal in canalblog: try: - o = urlparse(args.canalblog) + o = urlparse(canal) o = o._replace(scheme="https") url = o.geturl().replace(":///", "://") except Exception as err: logger.error("parsing error : {0}".format(err)) exit(1) - exportWp = WPExport.WPExport(url, logger, args.parser, args.directory) - webpage = exportWp.getUrlPage() - importWp.fromUrl(webpage) - - - if args.command == "export": - try: - o = urlparse(args.url) - o = o._replace(scheme="https") - url = o.geturl().replace(":///", "://") - except Exception as err: - logger.error("parsing error : {0}".format(err)) - exit(1) - exportWp = WPExport.WPExport(url, logger, args.parser, args.directory) - if args.js is False: - exportWp.downloadJs() + exportWp.setUrl(url) + if args.js is False: + exportWp.downloadJs() - if args.css is False: - exportWp.downloadCss() + if args.css is False: + exportWp.downloadCss() - if args.html is False or args.img is False: - webpage = exportWp.getUrlPage() - if args.html is False: - exportWp.downloadHTML(webpage) + if args.html is False or args.img is False: + webpage = exportWp.getUrlPage() + if args.html is False: + exportWp.downloadHTML(webpage) - if args.img is False: - exportWp.downloadImg(webpage) + if args.img is False: + exportWp.downloadImg(webpage) exit(0) \ No newline at end of file