async def get_url(self, host, payload): async with aiohttp.ClientSession() as session: async with session.post(host, data=payload) as resp: text = await resp.text() if "1" in text: print(text, payload["key"])
async def consumer(self): while True: param = await self.work_queue.get() if param: await self.get_url(self.host, param) self.work_queue.task_done() else: break
async def producer(self): i = 0 string = '866260035710238' while 1: if i: md5_str = hashlib.md5(string.encode('utf-8')) self.payload["key"] = md5_str.hexdigest() string = str(int(string) + 1) await self.work_queue.put(self.payload.copy()) #必须要 i += 1 if i > self.max_loop: break
近期评论