當前位置: 首頁>>代碼示例>>Python>>正文


Python domain.TLD類代碼示例

本文整理匯總了Python中crits.domains.domain.TLD的典型用法代碼示例。如果您正苦於以下問題:Python TLD類的具體用法?Python TLD怎麽用?Python TLD使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TLD類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

 def __init__(self):
     self.rules = {}
     etlds = TLD.objects()
     for etld in etlds:
         tld = etld.tld.split('.')[-1]
         self.rules.setdefault(tld, [])
         self.rules[tld].append(re.compile(self.regexpize(etld.tld)))
開發者ID:0x3a,項目名稱:crits,代碼行數:7,代碼來源:handlers.py

示例2: populate_tlds

def populate_tlds(drop):
    """
    Populate default set of TLDs into the system.

    :param drop: Drop the existing collection before trying to populate.
    :type: boolean
    """

    if not drop:
        print "Drop protection does not apply to effective TLDs"
    TLD.drop_collection()
    f = os.path.join(settings.SITE_ROOT, '..', 'extras', 'effective_tld_names.dat')
    count = 0
    for line in open(f, 'r').readlines():
        line = line.strip()
        if line and not line.startswith('//'):
            TLD.objects(tld=line).update_one(set__tld=line, upsert=True)
            count += 1
    print "Effective TLDs: added %s TLDs!" % count
開發者ID:971sec,項目名稱:crits,代碼行數:19,代碼來源:create_default_collections.py

示例3: update_tlds

def update_tlds(data=None):
    """
    Update the TLD list in the database.

    :param data: The TLD data.
    :type data: file handle.
    :returns: dict with key "success" (boolean)
    """

    if not data:
        return {'success': False}
    line = data.readline()
    while line:
        line = line.rstrip()
        if line and not line.startswith('//'):
            TLD.objects(tld=line).update_one(set__tld=line, upsert=True)
        line = data.readline()

    # Update the package local tld_parser with the new domain info
    tld_parser = etld()

    return {'success': True}
開發者ID:0x3a,項目名稱:crits,代碼行數:22,代碼來源:handlers.py

示例4: extract_emails

def extract_emails(data):
    pattern = r'[a-zA-Z0-9-\.\+][email protected][a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?[\.[a-zA-Z]{2,}'
    emails = [each for each in re.findall(pattern, data) if len(each) > 0]
    final_emails = []
    for item in emails:
        if len(item) > 1 and item.find('.') != -1:
            try:
                tld = item.split(".")[-1]
                check = TLD.objects(tld=tld).first()
                if check:
                    final_emails.append(item)
            except:
                pass
    return final_emails
開發者ID:TheDr1ver,項目名稱:crits_services,代碼行數:14,代碼來源:__init__.py


注:本文中的crits.domains.domain.TLD類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。