本文整理汇总了Python中resource.Resource.isAPage方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.isAPage方法的具体用法?Python Resource.isAPage怎么用?Python Resource.isAPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource.Resource
的用法示例。
在下文中一共展示了Resource.isAPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_update_the_resource_when_it_attempts_a_redirect
# 需要导入模块: from resource import Resource [as 别名]
# 或者: from resource.Resource import isAPage [as 别名]
def test_should_update_the_resource_when_it_attempts_a_redirect(self):
web = TestWeb()
url = "http://localhost:5000/redirect"
web.head = self.redirect
resource = Resource('Page', 'http://localhost:5000', web)
resource.isAPage()
web.head = lambda x: FakeResponse('Content', 'application/pdf')
self.assertEqual(resource.name, "redirect.pdf")
self.assertEqual(resource.url, "http://localhost:5000/redirect.pdf")
示例2: resources
# 需要导入模块: from resource import Resource [as 别名]
# 或者: from resource.Resource import isAPage [as 别名]
def resources(self):
files = []
anchors = self.find_links_in_content(self.markup)
for anchor in anchors:
resource = Resource(anchor.getText(), anchor.get('href'), self.web, "http://elearning.uni-heidelberg.de/mod/resource/")
if resource.url == '' or resource.isOnExternalWebsite():
continue
try:
if resource.isAPage():
content = resource.load()
f = Page(content, self.web).resources()
files.append(f)
else:
files.append(resource)
except urllib2.HTTPError as e:
debug("Could not retrieve %s." % resource.url)
continue
return deflate(files)
示例3: test_should_indicate_that_the_resource_is_a_page
# 需要导入模块: from resource import Resource [as 别名]
# 或者: from resource.Resource import isAPage [as 别名]
def test_should_indicate_that_the_resource_is_a_page(self):
web = TestWeb()
web.response = FakeResponse("Content", "text/html")
resource = Resource("any", "any", web)
self.assertTrue(resource.isAPage())