本文整理汇总了Python中crits.domains.domain.TLD.objects方法的典型用法代码示例。如果您正苦于以下问题:Python TLD.objects方法的具体用法?Python TLD.objects怎么用?Python TLD.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crits.domains.domain.TLD
的用法示例。
在下文中一共展示了TLD.objects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from crits.domains.domain import TLD [as 别名]
# 或者: from crits.domains.domain.TLD import objects [as 别名]
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)))
示例2: populate_tlds
# 需要导入模块: from crits.domains.domain import TLD [as 别名]
# 或者: from crits.domains.domain.TLD import objects [as 别名]
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
示例3: update_tlds
# 需要导入模块: from crits.domains.domain import TLD [as 别名]
# 或者: from crits.domains.domain.TLD import objects [as 别名]
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}
示例4: extract_emails
# 需要导入模块: from crits.domains.domain import TLD [as 别名]
# 或者: from crits.domains.domain.TLD import objects [as 别名]
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