|
@@ -18,16 +18,19 @@ class Emotions(object):
|
|
header= {
|
|
header= {
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.142.86 Safari/537.36"
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.142.86 Safari/537.36"
|
|
}
|
|
}
|
|
- def __init__(self):
|
|
|
|
|
|
+ def __init__(self, params: dict, debug=False):
|
|
|
|
+ self.params = params
|
|
self.sess = httpx.Client(headers=self.header)
|
|
self.sess = httpx.Client(headers=self.header)
|
|
- self.path = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
- if not os.path.exists(self.path+'/data'):
|
|
|
|
- os.mkdir(self.path+'/data')
|
|
|
|
- self.data_path = self.path+'/data/'
|
|
|
|
- self.pool = ThreadPoolExecutor(2)
|
|
|
|
|
|
+ self.app_path=params["app_path"]
|
|
|
|
+ if not os.path.exists(self.app_path+'/data'):
|
|
|
|
+ os.mkdir(self.app_path+'/data')
|
|
|
|
+ self.data_path = self.app_path+'/data/'
|
|
|
|
+ self.pool = ThreadPoolExecutor(params['threads'])
|
|
|
|
|
|
def run(self):
|
|
def run(self):
|
|
- for i in range(1, 4328+1):
|
|
|
|
|
|
+ page_start=self.params["page_start"]
|
|
|
|
+ page_end=self.params["page_end"]
|
|
|
|
+ for i in range(page_start, page_end+1):
|
|
url = self._url.format(page=i)
|
|
url = self._url.format(page=i)
|
|
self.pool.submit(self.get_page, url)
|
|
self.pool.submit(self.get_page, url)
|
|
|
|
|
|
@@ -48,6 +51,5 @@ class Emotions(object):
|
|
break
|
|
break
|
|
print('下载完毕: ', url)
|
|
print('下载完毕: ', url)
|
|
|
|
|
|
- def __del__(self):
|
|
|
|
- self.pool.shutdown(wait=True)
|
|
|
|
-
|
|
|
|
|
|
+ def __del__(self):
|
|
|
|
+ self.pool.shutdown(wait=True)
|