예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
    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)
예제 #4
0
 def test_UnknownEnumLevel(self):
     self.assertEqual(AnonymityLevel.UNKNOWN, AnonymityLevel.get('unknown'))
     self.assertEqual(AnonymityLevel.UNKNOWN, AnonymityLevel.get('none'))
     self.assertEqual(AnonymityLevel.UNKNOWN, AnonymityLevel.get('bad'))
     self.assertEqual(AnonymityLevel.UNKNOWN, AnonymityLevel.get(''))
     self.assertEqual(AnonymityLevel.UNKNOWN, AnonymityLevel.get('*'))
     self.assertEqual(AnonymityLevel.UNKNOWN, AnonymityLevel.get('??'))
 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)
예제 #6
0
 def test_EliteEnumLevel(self):
     self.assertEqual(AnonymityLevel.ELITE, AnonymityLevel.get('elite'))
     self.assertEqual(AnonymityLevel.ELITE, AnonymityLevel.get('elite proxy'))
     self.assertEqual(AnonymityLevel.ELITE, AnonymityLevel.get('HIGH'))
     self.assertEqual(AnonymityLevel.ELITE, AnonymityLevel.get('Elite & Anonymous'))
예제 #7
0
 def test_AnonymousEnumLevel(self):
     self.assertEqual(AnonymityLevel.ANONYMOUS, AnonymityLevel.get('anonymous'))
     self.assertEqual(AnonymityLevel.ANONYMOUS, AnonymityLevel.get('anonymous proxy'))
     self.assertEqual(AnonymityLevel.ANONYMOUS, AnonymityLevel.get('high-anonymous'))
예제 #8
0
 def test_TransparentEnumLevel(self):
     self.assertEqual(AnonymityLevel.TRANSPARENT, AnonymityLevel.get('transparent'))
     self.assertEqual(AnonymityLevel.TRANSPARENT, AnonymityLevel.get('transparent proxy'))
     self.assertEqual(AnonymityLevel.TRANSPARENT, AnonymityLevel.get('LOW'))