def get_yaca_image(cls, site): from yandex_ci_parser.yaca import YacaCi url = YacaCi.get_url(site) res = requests.get(url) res.raise_for_status() try: ci = YacaCi.result(res.text, site) except IncorrectParserError: from yandex_ci_parser.image import ImageCi url = ImageCi.get_url(site) res = requests.get(url) res.raise_for_status() ci = ImageCi.result(res.content) return ci
def get_image(cls, site): from yandex_ci_parser.image import ImageCi url = ImageCi.get_url(site) res = requests.get(url) res.raise_for_status() return ImageCi.result(res.text)
def test1(self): content = self.get_data('ci-apartlux.ru.gif') res = ImageCi.result(content) self.assertEqual(res, 150)
def test4(self): content = self.get_data('ci-yandex.ru.gif') res = ImageCi.result(content) self.assertEqual(res, 500000)
def test3(self): content = self.get_data('ci-titapet.ru.gif') res = ImageCi.result(content) self.assertEqual(res, None)
def test2(self): content = self.get_data('ci-bdbd.ru.gif') res = ImageCi.result(content) self.assertEqual(res, 1600)