从hash中随机返回一个代理 :return:
(self, https)
| 48 | **kwargs)) |
| 49 | |
| 50 | def get(self, https): |
| 51 | """ |
| 52 | 从hash中随机返回一个代理 |
| 53 | :return: |
| 54 | """ |
| 55 | if https: |
| 56 | items_dict = self.__conn.hgetall(self.name) |
| 57 | proxies = list(filter(lambda x: json.loads(x).get("https"), items_dict.values())) |
| 58 | return choice(proxies) if proxies else None |
| 59 | else: |
| 60 | proxies = self.__conn.hkeys(self.name) |
| 61 | proxy = choice(proxies) if proxies else None |
| 62 | return self.__conn.hget(self.name, proxy) if proxy else None |
| 63 | |
| 64 | def put(self, proxy_obj): |
| 65 | """ |