{"id":17249,"date":"2020-02-02T22:50:41","date_gmt":"2020-02-02T14:50:41","guid":{"rendered":"http:\/\/4563.org\/?p=17249"},"modified":"2020-02-02T22:50:41","modified_gmt":"2020-02-02T14:50:41","slug":"%e6%b8%85%e5%8d%8e%e6%96%87%e6%b3%89%e5%ad%a6%e5%a0%82%e5%8d%8f%e7%a8%8b%e4%b8%8b%e8%bd%bd","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=17249","title":{"rendered":"\u6e05\u534e\u6587\u6cc9\u5b66\u5802\u534f\u7a0b\u4e0b\u8f7d"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>yjsx86<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>\u6e05\u534e\u6587\u6cc9\u5b66\u5802\u534f\u7a0b\u4e0b\u8f7d<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 yjsx86 \u4e8e 2020-2-2 22:08 \u7f16\u8f91 <\/p>\n<p> \u534f\u7a0b\u4e0b\u8f7d\uff0c \u589e\u52a0\u4e0b\u8f7d\u901f\u5ea6\uff0c \u8bd5\u8bd5\u770b<br \/>  github\u4e0a\u90a3\u4e2a\u8bd5\u7528\u4e86\u4e00\u4e0b \u4f1a\u51fa\u73b0not found \u8fd8\u662fnot load \u6765\u7740\u5bfc\u81f4\u4e0b\u8f7d\u5931\u8d25<br \/>  \u8fd9\u4e2a\u4f1a\u628a\u4e0b\u8f7d\u5931\u8d25\u7684\u91cd\u56de\u961f\u5217\uff0c \u6700\u7ec8\u4f1a\u4e0b\u8f7d\u6210\u529f\u7684(\u6d4b\u8bd5\u7684\u65f6\u5019\u6709\u4e24\u5f20\u56fe\u603b\u662f\u4e0b\u8f7d\u5931\u8d25\uff0c \u7a0b\u5e8f\u91cd\u8bd5\u4e86\u4e0a\u767e\u6b21\u540e\u6210\u529f\u4e86\uff01)<br \/>  import requests<br \/>  import jwt<br \/>  import json<br \/>  import time<br \/>  import aiohttp<br \/>  import asyncio<br \/>  import os<br \/>  import logging<\/p>\n<p>  logging.basicConfig(level=logging.INFO)<\/p>\n<p>  class Wqxuetang():<\/p>\n<p>  &nbsp; &nbsp; def __init__(self, bookid, max_threads=4):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.bookid = bookid<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.max_threads = max_threads<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.work_queue = asyncio.Queue()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.jwt_secret = &quot;g0NnWdSE8qEjdMD8a1aq12qEYphwErKctvfd3IktWHWiOBpVsgkecur38aBRPn2w&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.session = requests.session()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.jwtkey = self.get_jwt_key()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.timeoutlist = []<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;(self.bookname, self.totalpages) = self.bookinfo()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.totalpages = int(self.totalpages)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.creat_and_enter_book_dir()<\/p>\n<p>  &nbsp; &nbsp; def creat_and_enter_book_dir(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;curpath = os.getcwd()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;newpath = curpath + os.path.sep + self.bookname<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;os.mkdir(newpath)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;os.chdir(newpath)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<\/p>\n<p>  &nbsp; &nbsp; def bookinfo(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;url = f&quot;https:\/\/lib-nuanxin.wqxuetang.com\/v1\/read\/initread?bid={self.bookid}&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;r = self.session.get(url)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;info = json.loads(r.text)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;data = info[&#8216;data&#8217;]<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;return data[&#8216;name&#8217;], data[&#8216;canreadpages&#8217;]<\/p>\n<p>  &nbsp; &nbsp; def get_jwt_key(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;url = &quot;https:\/\/lib-nuanxin.wqxuetang.com\/v1\/read\/k?bid=%s&quot; % self.bookid<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;r = self.session.get(url, timeout=5)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;j = json.loads(r.text)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;return j[&#8216;data&#8217;]<\/p>\n<p>  &nbsp; &nbsp; def get_jwt_token(self, page):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;cur_time = time.time()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;jwttoken = jwt.encode({<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;p&quot;: page,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;t&quot;: int(cur_time)*1000,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;b&quot;: str(self.bookid),<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;w&quot;: 1000,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;k&quot;: json.dumps(self.jwtkey),<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;iat&quot;: int(cur_time)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;}, self.jwt_secret, algorithm=&#8217;HS256&#8242;).decode(&#8216;ascii&#8217;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;return jwttoken<\/p>\n<p>  &nbsp; &nbsp; async def download_img(self, page, task_id):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;token = self.get_jwt_token(page)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;url = f&quot;https:\/\/lib-nuanxin.wqxuetang.com\/page\/img\/{self.bookid}\/{page}?k={token}&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;headers = {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8216;referer&#8217;: f&#8217;https:\/\/lib-nuanxin.wqxuetang.com\/read\/pdf\/{self.bookid}&#8217;,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8216;user-agent&#8217;: &#8216;Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/69.0.3497.100 Safari\/537.36&#8217;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;}<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;try:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;async with aiohttp.ClientSession() as session:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; async with session.get(url, headers=headers, timeout=5) as response:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;r = await response.read()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;except Exception:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;logging.warning(f&quot;\u7ebf\u7a0b {task_id} -&gt; \u7b2c {page} \u5f20\u4e0b\u8f7d\u5931\u8d25, \u91cd\u56de\u961f\u5217\uff01\uff01\uff01&quot;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;self.work_queue.put_nowait(page)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;with open(f&quot;{self.bookname+str(page)}.png&quot;, &quot;wb&quot;) as f:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; f.write(r)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;logging.info(f&quot;\u7ebf\u7a0b {task_id} -&gt; \u7b2c {page} \u5f20\u4e0b\u8f7d\u5b8c\u6210&quot;)<\/p>\n<p>  &nbsp; &nbsp; async def handle_tasks(self, task_id):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;while not self.work_queue.empty():<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;page = await self.work_queue.get()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;await self.download_img(page, task_id)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;logging.info(f&quot;\u7ebf\u7a0b {task_id} \u7ed3\u675f\u5de5\u4f5c\uff01~&quot;)<\/p>\n<p>  &nbsp; &nbsp; def main(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;loop = asyncio.get_event_loop()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;tasks = <br \/>  &nbsp; &nbsp;&nbsp; &nbsp;loop.run_until_complete(asyncio.wait(tasks))<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;loop.close()<\/p>\n<p>  if __name__ == &quot;__main__&quot;:<br \/>  &nbsp; &nbsp; bookid = 3187882<br \/>  &nbsp; &nbsp; # \u53c2\u65701\uff1a\u4e66\u53f7\uff0c \u53c2\u65702\uff1a\u7ebf\u7a0b\u6570<br \/>  &nbsp; &nbsp; # \u9ed8\u8ba4\u4e66\u540d\u4e3a\u4e0b\u8f7d\u6587\u4ef6\u5939\u540d<br \/>  &nbsp; &nbsp; w = Wqxuetang(bookid, 4)<br \/>  &nbsp; &nbsp; w.main()<\/p>\n<p>  \t\t\t\t\t<strong>haierwx21410<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u9876\u4e00\u9876\uff0c\u8bf7\u95ee\u697c\u4e3b\uff0c\u8fd9\u4e2a\u4e0b\u8f7d\u4e0b\u6765\u662f\u56fe\u7247\u4e48\uff1f\u8fd8\u662fpdf\u554a\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>yjsx86<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\thaierwx21410 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-2-2 22:10<br \/>  \u9876\u4e00\u9876\uff0c\u8bf7\u95ee\u697c\u4e3b\uff0c\u8fd9\u4e2a\u4e0b\u8f7d\u4e0b\u6765\u662f\u56fe\u7247\u4e48\uff1f\u8fd8\u662fpdf\u554a<\/p>\n<p> \u4e0b\u8f7d\u4e0b\u6765\u7684\u56fe\u7247 \uff0c \u9700\u8981pdf\u7684\u8bdd\u81ea\u5df1\u5408\u6210\u5427\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>jxpal<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u9876\u4e00\u4e0b\uff0c\u987a\u4fbfmark\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u4e1c\u5357\u897f\u5317<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u9a6c\u514b\u4e00\u4e0b\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u675c\u752b<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\ud83d\ude42 \u6bcf\u5e74618\u4e70\u7684\u4e66\u5806\u6210\u5c71\u4e86\u90fd\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>vopcloud<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\timport requests<br \/>  import jwt<br \/>  import json<br \/>  import time<br \/>  import aiohttp<br \/>  import asyncio<br \/>  import os<br \/>  import logging<br \/>  import sys<\/p>\n<p>  logging.basicConfig(level=logging.INFO)<\/p>\n<p>  class Wqxuetang():<\/p>\n<p>  &nbsp; &nbsp; def __init__(self, bookid, max_threads=4):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.bookid = bookid<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.max_threads = max_threads<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.work_queue = asyncio.Queue()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.jwt_secret = &quot;g0NnWdSE8qEjdMD8a1aq12qEYphwErKctvfd3IktWHWiOBpVsgkecur38aBRPn2w&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.session = requests.session()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.jwtkey = self.get_jwt_key()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.timeoutlist = []<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;(self.bookname, self.totalpages) = self.bookinfo()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.totalpages = int(self.totalpages)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;self.creat_and_enter_book_dir()<\/p>\n<p>  &nbsp; &nbsp; def creat_and_enter_book_dir(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;curpath = os.getcwd()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;newpath = curpath + os.path.sep + self.bookname<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;os.mkdir(newpath)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;os.chdir(newpath)<\/p>\n<p>  &nbsp; &nbsp; def bookinfo(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;url = f&quot;https:\/\/lib-nuanxin.wqxuetang.com\/v1\/read\/initread?bid={self.bookid}&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;r = self.session.get(url)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;info = json.loads(r.text)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;data = info[&#8216;data&#8217;]<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;return data[&#8216;name&#8217;], data[&#8216;canreadpages&#8217;]<\/p>\n<p>  &nbsp; &nbsp; def get_jwt_key(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;url = &quot;https:\/\/lib-nuanxin.wqxuetang.com\/v1\/read\/k?bid=%s&quot; % self.bookid<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;r = self.session.get(url, timeout=5)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;j = json.loads(r.text)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;return j[&#8216;data&#8217;]<\/p>\n<p>  &nbsp; &nbsp; def get_jwt_token(self, page):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;cur_time = time.time()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;jwttoken = jwt.encode({<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;p&quot;: page,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;t&quot;: int(cur_time)*1000,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;b&quot;: str(self.bookid),<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;w&quot;: 1000,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;k&quot;: json.dumps(self.jwtkey),<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&quot;iat&quot;: int(cur_time)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;}, self.jwt_secret, algorithm=&#8217;HS256&#8242;).decode(&#8216;ascii&#8217;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;return jwttoken<\/p>\n<p>  &nbsp; &nbsp; async def download_img(self, page, task_id):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;token = self.get_jwt_token(page)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;url = f&quot;https:\/\/lib-nuanxin.wqxuetang.com\/page\/img\/{self.bookid}\/{page}?k={token}&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;headers = {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8216;referer&#8217;: f&#8217;https:\/\/lib-nuanxin.wqxuetang.com\/read\/pdf\/{self.bookid}&#8217;,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8216;user-agent&#8217;: &#8216;Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/69.0.3497.100 Safari\/537.36&#8217;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;}<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;try:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;async with aiohttp.ClientSession() as session:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; async with session.get(url, headers=headers, timeout=5) as response:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;r = await response.read()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;except Exception:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;logging.warning(f&quot;\u7ebf\u7a0b {task_id} -&gt; \u7b2c {page} \u5f20\u4e0b\u8f7d\u5931\u8d25, \u91cd\u56de\u961f\u5217\uff01\uff01\uff01&quot;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;self.work_queue.put_nowait(page)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;if sys.getsizeof(r)==10433:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; self.work_queue.put_nowait(page)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; logging.warning(f&quot;\u7ebf\u7a0b {task_id} -&gt; \u7b2c {page} \u5f20\u52a0\u8f7d\u5931\u8d25, \u91cd\u56de\u961f\u5217\uff01\uff01\uff01&quot;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; with open(f&quot;{self.bookname+str(page)}.png&quot;, &quot;wb&quot;) as f:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;f.write(r)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; logging.info(f&quot;\u7ebf\u7a0b {task_id} -&gt; \u7b2c {page} \u5f20\u4e0b\u8f7d\u5b8c\u6210&quot;)<\/p>\n<p>  &nbsp; &nbsp; async def handle_tasks(self, task_id):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;while not self.work_queue.empty():<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;page = await self.work_queue.get()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;await self.download_img(page, task_id)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;logging.info(f&quot;\u7ebf\u7a0b {task_id} \u7ed3\u675f\u5de5\u4f5c\uff01~&quot;)<\/p>\n<p>  &nbsp; &nbsp; def main(self):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;loop = asyncio.get_event_loop()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;tasks = <br \/>  &nbsp; &nbsp;&nbsp; &nbsp;loop.run_until_complete(asyncio.wait(tasks))<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;loop.close()<\/p>\n<p>  if __name__ == &quot;__main__&quot;:<br \/>  &nbsp; &nbsp; bookid = int(sys.argv)<br \/>  &nbsp; &nbsp; # \u53c2\u65701\uff1a\u4e66\u53f7\uff0c \u53c2\u65702\uff1a\u7ebf\u7a0b\u6570<br \/>  &nbsp; &nbsp; # \u9ed8\u8ba4\u4e66\u540d\u4e3a\u4e0b\u8f7d\u6587\u4ef6\u5939\u540d<br \/>  &nbsp; &nbsp; w = Wqxuetang(bookid, 4)<br \/>  &nbsp; &nbsp; w.main()<br \/>  \u697c\u4e3b\uff0c\u6211\u53d1\u73b0\u597d\u50cf\u6709\u4e9b\u4e0b\u8f7d\u4e0b\u6765\u7684\u56fe\u7247\u6709\u95ee\u9898\uff0c\u56fe\u7247\u90fd\u663e\u793a\u52a0\u8f7d\u4e2d\uff0c\u4f46\u662f\u8fd9\u4e9b\u4e0b\u8f7d\u5f02\u5e38\u7684\u56fe\u7247\u5927\u5c0f\u90fd\u4e00\u6837\uff0c\u5c31\u7b80\u5355\u7c97\u66b4\u52a0\u4e86\u4e2a\u5224\u65ad\uff0c\u4e0d\u77e5\u697c\u4e3b\u6709\u6ca1\u6709\u5565\u597d\u65b9\u6cd5\uff1f\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>yjsx86<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tvopcloud \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-2-2 22:46<br \/>  \u697c\u4e3b\uff0c\u6211\u53d1\u73b0\u597d\u50cf\u6709\u4e9b\u4e0b\u8f7d\u4e0b\u6765\u7684\u56fe\u7247\u6709\u95ee\u9898\uff0c\u56fe\u7247\u90fd\u663e\u793a\u52a0\u8f7d\u4e2d\uff0c\u4f46\u662f\u8fd9\u4e9b\u4e0b\u8f7d\u5f02\u5e38\u7684\u56fe\u7247\u5927\u5c0f\u90fd\u4e00\u6837\uff0c\u5c31\u7b80 &#8230;<\/p>\n<p> \u7ed9\u4e2abookid\u6211\u8bd5\u8bd5\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>yjsx86 \u5927\u4f6c\u6709\u8bdd\u8bf4 : \u6e05\u534e&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/17249"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17249"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/17249\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17249"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}