什么时候" a"发布,图像" b"也被张贴了。如何制作图像" c"发布" a"在" a"之后发布了一张图片" b"?

时间:2016-03-26 04:07:40

标签: javascript jquery python django

抱歉,如果标题非常混乱。在我的网站上,当用户发布网址时,我设置的默认图片会与网址一起发布。因此,如果很多用户发布了url,那么同一个默认图像会多次显示在我的网站上。因为,我很无聊,我想混淆图像。我希望拥有多个图像,并且每个图像在用户发布网址时一个接一个地显示。

import json
from goose import Goose

DEFAULT = 'https://images.unsplash.com/photo-1417028441456-f283323fe2d6?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=c48033d726ec5227264b186342c0a8e5'
DEFAULT1 = 'https://images.unsplash.com/photo-1452447224378-04c089d77aa4?crop=entropy&fit=crop&fm=jpg&h=800&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=1550'
def extract(url):
    g = Goose()
    try:
        article = g.extract(url=url)
        if article.top_image is None:
            return DEFAULT 

        else:
            if article.top_image.src is None:
              return DEFAULT1
            else:
                resposne = {'image':article.top_image.src}
                return article.top_image.src
    except ParseError:
        if can_handle():
                handle_exception()
            else:
                print("couldn't handle exception: url={0}".format(url))
                raise 

我希望有更多的图像和要使用的图像,而不仅仅是一个DEFAULT图像。我该怎么做?

0 个答案:

没有答案