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


Python Lassie.fetch方法代码示例

本文整理汇总了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)
开发者ID:josephmartz,项目名称:lassie,代码行数:15,代码来源:test_core.py

示例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'])
开发者ID:michaelhelmick,项目名称:lassie,代码行数:9,代码来源:test_amp.py

示例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'])
开发者ID:mbeacom,项目名称:lassie,代码行数:9,代码来源:test_core.py

示例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'])
开发者ID:michaelhelmick,项目名称:lassie,代码行数:9,代码来源:test_amp.py

示例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']))
开发者ID:michaelhelmick,项目名称:lassie,代码行数:9,代码来源:test_amp.py

示例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']))
开发者ID:michaelhelmick,项目名称:lassie,代码行数:9,代码来源:test_amp.py

示例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']))
开发者ID:michaelhelmick,项目名称:lassie,代码行数:9,代码来源:test_amp.py

示例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'))
开发者ID:mbeacom,项目名称:lassie,代码行数:9,代码来源:test_youtube.py

示例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']))
开发者ID:michaelhelmick,项目名称:lassie,代码行数:9,代码来源:test_amp.py

示例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)
开发者ID:mbeacom,项目名称:lassie,代码行数:10,代码来源:test_youtube.py

示例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)
开发者ID:josephmartz,项目名称:lassie,代码行数:11,代码来源:test_core.py

示例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)
开发者ID:josephmartz,项目名称:lassie,代码行数:12,代码来源:test_core.py

示例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)
开发者ID:michaelhelmick,项目名称:lassie,代码行数:12,代码来源:test_amp.py

示例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)
开发者ID:Mirona,项目名称:lassie,代码行数:14,代码来源:test_core.py

示例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)
开发者ID:josephmartz,项目名称:lassie,代码行数:25,代码来源:test_core.py


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