Example #1
0
 def get(self):
     content = ''
     page = Page.query(Page.Path == self.request.path).get()
     if page == None:
         page = Page.query(Page.Path == '404').get()
         if page == None:
             content = '404 Not Found'
         else:
             content = page.Content
     else:
         content = page.Content
     self.write(content)
Example #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)
Example #3
0
def parse(html):
    document = Selector(text=html)
    memes = [
        catch_errors(parse_meme, element) for element in document.css("article.story")
    ]
    memes = [meme for meme in memes if meme is not None]
    title = document.css("title::text").get()
    next_page_url = "/anonimowe/page/" + find_id_in_url(
        document.css("nav.pagination > div.next > a::attr(href)").get()
    )
    return Page(title, memes, next_page_url)
Example #4
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)
Example #5
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)
Example #6
0
def parse(raw, nsfw=False):
    json = loads(raw)
    posts = json["data"]["posts"]
    memes = [catch_errors(parse_meme, post) for post in posts]
    memes = [meme for meme in memes if meme is not None]

    next_page_url = None
    result = NEXT_CURSOR.match(json["data"]["nextCursor"])
    if result:
        if nsfw is True:
            next_page_url = "/9gagnsfw/page/" + result.group(1)
        else:
            next_page_url = "/9gag/page/" + result.group(1)

    return Page(None, memes, next_page_url)