本文整理汇总了Python中lassie.Lassie.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python Lassie.fetch方法的具体用法?Python Lassie.fetch怎么用?Python Lassie.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lassie.Lassie
的用法示例。
在下文中一共展示了Lassie.fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_core_class_vs_method_settings
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_core_class_vs_method_settings(self):
url = "http://lassie.it/core/class_vs_method_settings.html"
l = Lassie()
data = l.fetch(url)
self.assertEqual(len(data["images"]), 1)
l.open_graph = False
data = l.fetch(url)
# open_graph is set to False so there shouldn't be any images in the list this time around
self.assertEqual(len(data["images"]), 0)
示例2: test_bad_json
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_bad_json(self):
url = 'http://lassie.it/amp/bad_json.html'
l = Lassie()
data = l.fetch(url)
self.assertTrue('amp' in data['url'])
示例3: test_no_html_tag
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_no_html_tag(self):
url = 'http://lassie.it/core/no_html_tag.html'
l = Lassie()
data = l.fetch(url)
self.assertTrue('no_html_tag' in data['title'])
示例4: test_list_json
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_list_json(self):
url = 'http://lassie.it/amp/list_json.html'
l = Lassie()
data = l.fetch(url)
self.assertTrue('Pixar' in data['description'])
示例5: test_str_image
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_str_image(self):
url = 'http://lassie.it/amp/str_image.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(1, len(data['images']))
示例6: test_video_objects
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_video_objects(self):
url = 'http://lassie.it/amp/video_objects.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(1, len(data['videos']))
示例7: test_list_thumbnail_image
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_list_thumbnail_image(self):
url = 'http://lassie.it/amp/list_thumbnail_image.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(2, len(data['images']))
示例8: test_bad_url
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_bad_url(self):
url = 'http://lassie.it/youtube/bad_url_123456.json'
l = Lassie()
data = l.fetch(url)
self.assertIsNone(data.get('oembed'))
示例9: test_list_image_empty
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_list_image_empty(self):
url = 'http://lassie.it/amp/list_image_empty.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(1, len(data['images']))
示例10: test_youtube_good
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_youtube_good(self):
url = 'http://lassie.it/youtube/good.json'
l = Lassie()
data = l.fetch(url)
self.assertEqual(len(data['videos']), 1)
self.assertEqual(len(data['images']), 1)
示例11: test_core_class_setting_is_none
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_core_class_setting_is_none(self):
url = "http://lassie.it/core/class_setting_is_none.html"
# This is a really odd use-case where they'd set the class attr to None, but it might happen so oh wellz.
l = Lassie()
l.open_graph = None
data = l.fetch(url, open_graph=False)
self.assertEqual(len(data["images"]), 0)
示例12: test_bad_image_dimensions
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_bad_image_dimensions(self):
url = "http://lassie.it/core/bad_image_dimensions.html"
l = Lassie()
data = l.fetch(url, all_images=True)
# lassie.utils.convert_to_int will except a TypeError or ValueError and pass (not setting a width/height on the image)
image = data["images"][0]
self.assertTrue(not "width" in image)
self.assertTrue(not "height" in image)
示例13: test_all_properites
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_all_properites(self):
url = 'http://lassie.it/amp/all_properties.html'
l = Lassie()
data = l.fetch(url, all_images=True)
self.assertEqual(len(data['images']), 3)
title = 'Google Glass Is Dead, Long Live Snapchat Spectacles'
self.assertEqual(data['title'], title)
示例14: test_core_retrieve_all_images
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_core_retrieve_all_images(self):
url = 'http://lassie.it/core/retrieve_all_images.html'
l = Lassie()
l.all_images = True
data = l.fetch(url)
self.assertEqual(len(data['images']), 3)
last_image = data['images'][2]
self.assertEqual(last_image['width'], 550)
self.assertEqual(last_image['height'], 365)
示例15: test_image_dimensions
# 需要导入模块: from lassie import Lassie [as 别名]
# 或者: from lassie.Lassie import fetch [as 别名]
def test_image_dimensions(self):
url = "http://lassie.it/core/image_dimensions.html"
l = Lassie()
data = l.fetch(url, all_images=True)
self.assertEqual(len(data["images"]), 4)
image = data["images"][0]
self.assertEqual(image["width"], 100)
self.assertEqual(image["height"], 100)
image = data["images"][1]
self.assertEqual(image["width"], 100)
self.assertEqual(image["height"], 100)
image = data["images"][2]
self.assertEqual(image["width"], 100)
self.assertEqual(image["height"], 100)
image = data["images"][3]
self.assertEqual(image["width"], 100)
self.assertEqual(image["height"], 100)