add WPChange
This commit is contained in:
parent
c631909cb6
commit
16368c13bb
@ -9,6 +9,13 @@ import argparse, logging, threading
|
||||
from lib.WPImport import WPimport
|
||||
from lib.WPExport import WPExport
|
||||
from lib.WPRemove import WPRemove
|
||||
from lib.WPChange import WPChange
|
||||
|
||||
def change(index, number, args, logger):
|
||||
changeWp = WPChange(logger=logger, index_name=index, number_thread=number)
|
||||
changeWp.fromDirectory(args.directory)
|
||||
|
||||
del changeWp
|
||||
|
||||
def remove(index, number, args, basic, logger, ssl_wordpress):
|
||||
removeWp = WPRemove(basic=basic, wordpress="", logger=logger, ssl_wordpress=ssl_wordpress, index_name=index, number_thread=number)
|
||||
@ -172,7 +179,15 @@ if __name__ == '__main__':
|
||||
export_parser.add_argument("--no-img", help="No img", dest="img", action="store_true")
|
||||
export_parser.add_argument("--no-html", help="No HTML", dest="html", action="store_true")
|
||||
|
||||
|
||||
change_parser = subparsers.add_parser("change")
|
||||
change_parser.add_argument("--directory",
|
||||
default="",
|
||||
help="Directory")
|
||||
change_parser.add_argument("--file",
|
||||
default="",
|
||||
help="File")
|
||||
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -293,4 +308,17 @@ if __name__ == '__main__':
|
||||
wait_for = [ ex.submit(remove, i, args.parallel, args, basic, logger, ssl_wordpress) for i in range(0, int(args.parallel)) ]
|
||||
except Exception as err:
|
||||
logger.error("Thread error for remove : {0}".format(err))
|
||||
exit(0)
|
||||
|
||||
if args.command == "change":
|
||||
if len(args.directory) > 0:
|
||||
try:
|
||||
with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex:
|
||||
wait_for = [ ex.submit(change, i, args.parallel, args, logger) for i in range(0, int(args.parallel)) ]
|
||||
except Exception as err:
|
||||
logger.error("Thread error for remove : {0}".format(err))
|
||||
if len(args.file) > 0:
|
||||
changeWp = WPChange(logger=logger)
|
||||
for filei in args.file.split(","):
|
||||
changeWp.fromFile(filei)
|
||||
exit(0)
|
@ -2,7 +2,7 @@ from bs4 import BeautifulSoup
|
||||
from urllib.parse import urlparse
|
||||
import requests, os, logging, re, json
|
||||
|
||||
class WPRemove:
|
||||
class WPChange:
|
||||
# Constructor
|
||||
def __init__(self, index_name=1, number_thread=1, logger=None, parser="html.parser"):
|
||||
self._name = "Thread-{0}".format(index_name)
|
||||
@ -76,5 +76,8 @@ class WPRemove:
|
||||
content = f.read()
|
||||
soup = BeautifulSoup(content, self._parser)
|
||||
img = soup.find_all("img")
|
||||
for i in img:
|
||||
src = i.get("src")
|
||||
self._logger.info(src)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user