fix thread in parallelism
This commit is contained in:
parent
0acd5067cb
commit
08ff16527d
@ -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))
|
||||
]
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user