Exemplo n.º 1
0
def parse_meme(m):
    title = html.unescape(m["title"])
    url = m["url"]

    comment_count = int(m["commentsCount"])
    points = int(m["upVoteCount"]) - int(m["downVoteCount"])
    tags = [Tag(tag["key"], ROOT + tag["url"]) for tag in m["tags"]]

    content = None

    # Determine type
    t = m["type"]
    if t == "Animated":
        for k, v in m["images"].items():
            if "duration" in v:
                content = VideoContent(v["url"])
    else:
        src = m["images"]["image700"]["url"]
        content = ImageContent(src)

    return Meme(
        title,
        url,
        "/9gag/{}".format(get_last_part_url(url)),
        content,
        None,
        tags,
        points,
        comment_count,
    )
Exemplo n.º 2
0
def parse(html):
    document = Selector(text=html)
    memes = [
        catch_errors(parse_meme, element)
        for element in document.css("main .media-element")
    ]
    memes = [meme for meme in memes if meme is not None]
    title = document.css("title::text").get()
    next_page_url = "/kwejk/page/" + get_last_part_url(
        document.css(".btn-next::attr(href)").get())
    return Page(title, memes, next_page_url)
Exemplo n.º 3
0
def parse(html):
    document = Selector(text=html)
    memes = [
        catch_errors(parse_meme, element)
        for element in document.css(".demotivator")
    ]
    memes = [meme for meme in memes if meme is not None]

    title = document.css("title::text").get()
    next_page_url = "/demotywatory/page/" + get_last_part_url(
        document.css("a.next-page::attr(href)").get())
    return Page(title, memes, next_page_url)
Exemplo n.º 4
0
def parse(html):
    document = Selector(text=html)
    memes = [
        catch_errors(parse_meme, element)
        for element in document.css("div.pic")
    ]
    memes = [meme for meme in memes if meme is not None]

    title = document.css("title::text").get()
    next_page_url = "/mistrzowie/page/" + get_last_part_url(
        document.css(".list_next_page_button::attr(href)").get())
    return Page(title, memes, next_page_url)
Exemplo n.º 5
0
 def fake_download(url):
     f = "demot-{}.html".format(utils.get_last_part_url(url))
     if f in files:
         return files[f]
     raise Exception()