本文整理匯總了Python中holmes.models.Domain.get_domain_names方法的典型用法代碼示例。如果您正苦於以下問題:Python Domain.get_domain_names方法的具體用法?Python Domain.get_domain_names怎麽用?Python Domain.get_domain_names使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類holmes.models.Domain
的用法示例。
在下文中一共展示了Domain.get_domain_names方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: save_request
# 需要導入模塊: from holmes.models import Domain [as 別名]
# 或者: from holmes.models.Domain import get_domain_names [as 別名]
def save_request(self, url, response):
if not response:
return
request_time = response.request_time
effective_url = response.effective_url
status_code = response.status_code
domain_name, domain_url = get_domain_from_url(url)
if domain_name not in Domain.get_domain_names(self.db):
return
req = Request(
domain_name=domain_name,
url=url,
effective_url=effective_url,
status_code=int(status_code),
response_time=request_time,
completed_date=datetime.now().date(),
review_url=self.page_url
)
self.db.add(req)
self.cache.increment_requests_count()
self.publish(dumps({
'type': 'new-request',
'url': str(url)
}))
示例2: save_request
# 需要導入模塊: from holmes.models import Domain [as 別名]
# 或者: from holmes.models.Domain import get_domain_names [as 別名]
def save_request(self, url, response):
if not response:
return
request_time = response.request_time
effective_url = response.effective_url
status_code = response.status_code
if self.domain_name not in Domain.get_domain_names(self.db):
return
req = Request(
domain_name=self.domain_name,
url=url,
effective_url=effective_url,
status_code=int(status_code),
response_time=request_time,
completed_date=datetime.now().date(),
review_url=self.page_url
)
self.db.add(req)
url = url.encode('utf-8')
self.publish(dumps({
'type': 'new-request',
'url': str(url)
}))
示例3: test_get_domain_names
# 需要導入模塊: from holmes.models import Domain [as 別名]
# 或者: from holmes.models.Domain import get_domain_names [as 別名]
def test_get_domain_names(self):
self.db.query(Domain).delete()
DomainFactory.create(name="g1.globo.com")
DomainFactory.create(name="globoesporte.globo.com")
domain_names = Domain.get_domain_names(self.db)
expect(domain_names).to_be_like([
'g1.globo.com',
'globoesporte.globo.com'
])