当前位置: 首页>>代码示例>>Python>>正文


Python Resource.isAPage方法代码示例

本文整理汇总了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")
开发者ID:cessor,项目名称:scrape,代码行数:12,代码来源:test_resource.py

示例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)
开发者ID:cessor,项目名称:scrape,代码行数:23,代码来源:page.py

示例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())
开发者ID:cessor,项目名称:scrape,代码行数:7,代码来源:test_resource.py


注:本文中的resource.Resource.isAPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。