def test_ProxyObjectSimple(self): src = 'Test' ip = '127.0.0.1' port = '8080' po = ProxyObject(src, ip, port, AnonymityLevel.UNKNOWN) self.assertEqual(po.source, src) self.assertEqual(po.ip, ip) self.assertEqual(po.port, port) self.assertEqual(po.get_address(), "{0}:{1}".format(ip, port))
def create_proxy_object(self, dataset): # Check Field[0] for tags and field[1] for values! ip = "" port = None anonymity = AnonymityLevel.UNKNOWN country = None for field in dataset: if field[0] == 'IP Address': # Make sure it is a Valid IP ip = field[1].strip() # String strip() # Make sure it is a Valid IP if not UrlParser.valid_ip(ip): logger.debug("IP with Invalid format: {}".format(ip)) return None elif field[0] == 'Port': port = field[1].strip() # String strip() elif field[0] == 'Anonymity': anonymity = AnonymityLevel.get( field[1].strip()) # String strip() elif field[0] == 'Country': country = field[1].strip() # String strip() return ProxyObject(source=self.id, ip=ip, port=port, anonymity_level=anonymity, country=country)
def create_proxy_object(self, dataset): ip = "" port = None anonymity = AnonymityLevel.UNKNOWN country = None # Check Field[0] for tags and field[1] for values! for field in dataset: # Discard slow proxies! Speed is in KB/s if field[0] == 'Speed': if float(field[1]) < self.get_min_bandwidth(): logger.debug("Proxy with low bandwidth: {}".format(float(field[1]))) return None if field[0] == 'IP': ip = field[1].strip() # String strip() # Make sure it is a Valid IP if not UrlParser.valid_ip(ip): logger.debug("IP with Invalid format: {}".format(ip)) return None elif field[0] == 'Port': port = field[1].strip() # String strip() elif field[0] == 'Anon': anonymity = AnonymityLevel.get(field[1].strip()) # String strip() elif field[0] == 'Country': country = field[1].strip() # String strip() return ProxyObject(source=self.id, ip=ip, port=port, anonymity_level=anonymity, country=country)
def create_proxy_object(self, address, country, anonymity): # Make sure it is a Valid IP ip = address.strip().split(":")[0] if not UrlParser.valid_ip(ip): logger.debug("IP with Invalid format: {}".format(ip)) return None port = address.strip().split(":")[1] country = country.strip() anonymity = AnonymityLevel.get(anonymity.strip()) return ProxyObject(source=self.id, ip=ip, port=port, anonymity_level=anonymity, country=country)
def create_proxy_object(self, row): for td_row in row.findAll("td"): if td_row.attrs['data-label'] == 'IP:port ': text = td_row.text.strip() ip = text.split(":")[0] # Make sure it is a Valid IP if not UrlParser.valid_ip(ip): logger.debug("IP with Invalid format: {}".format(ip)) return None port = text.split(":")[1] elif td_row.attrs['data-label'] == 'Anonymity Type: ': anonymity = AnonymityLevel.get(td_row.text.strip()) elif td_row.attrs['data-label'] == 'Country: ': country = td_row.text.strip() return ProxyObject(source=self.id, ip=ip, port=port, anonymity_level=anonymity, country=country)