Пример #1
0
def presidencia_discursos():
    """
    ?limitstart=5
    Limita de 5 en 5 los discursos servira para que en el json se vayan recuperando
    en base a esa cantidad.
    """
    url = 'http://www.presidencia.gob.pe/discursos-del-presidente/blog'
    root = parse(url).getroot()
    news = []
    discursos = root.xpath("//div[@class='entryContent entry']")
    for discurso in discursos:
        descripcion = join([
            '<p>' + p.text_content() + '</p>'
            for p in discurso.xpath("div[@class='entry-body']")[0].xpath(
                "p[@style='text-align: justify;']")
        ], '')
        news.append(
            dict(
                titular=discurso.xpath("h2")[0].text_content(),
                link=u'%s%s' %
                ('http://presidencia.gob.pe/',
                 slugify(discurso.xpath("h2")[0].text_content())),
                descripcion=descripcion,
            ))
    return news
def presidencia_noticias():
    """
    ?limitstart=5
    Limita de 5 en 5 los discursos servira para que en el json se vayan recuperando
    en base a esa cantidad.
    """
    url = 'http://www.presidencia.gob.pe/ollanta/blog'
    root = parse(url).getroot()
    news = []    
    discursos = root.xpath("//div[@class='entryContent entry']")
    for discurso in discursos:
        #print discurso.xpath(
        #    "div[@class='entry-body']")[0].xpath(
        #    "p[@style='text-align: justify;']//em/img")
        descripcion = join(['<p>'+p.text_content()+'</p>'
            for p in discurso.xpath(
            "div[@class='entry-body']")[0].xpath(
            "p[@style='text-align: justify;']")],'')
        news.append(dict(
            titular = discurso.xpath("h2")[0].text_content(),
            link = u'%s%s' % ('http://presidencia.gob.pe/',
                slugify(discurso.xpath("h2")[0].text_content())),
            descripcion = descripcion,
            ))    
    return news
Пример #3
0
 def test_join(self):
     self.assertEqual(join([0, 1, 2], 'glue'), '0glue1glue2')
Пример #4
0
 def test_join(self):
     self.assertEqual(join([0, 1, 2], 'glue'), '0glue1glue2')
Пример #5
0
 def test_autoescape_off(self):
     self.assertEqual(
         join(['<a>', '<img>', '</a>'], '<br>', autoescape=False),
         '<a>&lt;br&gt;<img>&lt;br&gt;</a>',
     )
Пример #6
0
 def test_autoescape(self):
     self.assertEqual(
         join(['<a>', '<img>', '</a>'], '<br>'),
         '&lt;a&gt;&lt;br&gt;&lt;img&gt;&lt;br&gt;&lt;/a&gt;',
     )
Пример #7
0
 def test_noniterable_arg_autoescape_off(self):
     obj = object()
     self.assertEqual(join(obj, '<br>', autoescape=False), obj)
Пример #8
0
 def test_noniterable_arg(self):
     obj = object()
     self.assertEqual(join(obj, '<br>'), obj)
Пример #9
0
 def test_autoescape_off(self):
     self.assertEqual(
         join(['<a>', '<img>', '</a>'], '<br>', autoescape=False),
         '<a>&lt;br&gt;<img>&lt;br&gt;</a>',
     )
Пример #10
0
 def test_autoescape(self):
     self.assertEqual(
         join(['<a>', '<img>', '</a>'], '<br>'),
         '&lt;a&gt;&lt;br&gt;&lt;img&gt;&lt;br&gt;&lt;/a&gt;',
     )
Пример #11
0
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_DIRS = (join(BASE_DIR, 'static'), )
Пример #12
0
 def test_noniterable_arg_autoescape_off(self):
     obj = object()
     self.assertEqual(join(obj, '<br>', autoescape=False), obj)
Пример #13
0
 def test_noniterable_arg(self):
     obj = object()
     self.assertEqual(join(obj, '<br>'), obj)
Пример #14
0
 def test_autoescape_off(self):
     self.assertEqual(
         join(["<a>", "<img>", "</a>"], "<br>", autoescape=False),
         "<a>&lt;br&gt;<img>&lt;br&gt;</a>",
     )
Пример #15
0
 def test_autoescape(self):
     self.assertEqual(
         join(["<a>", "<img>", "</a>"], "<br>"),
         "&lt;a&gt;&lt;br&gt;&lt;img&gt;&lt;br&gt;&lt;/a&gt;",
     )
Пример #16
0
 def test_list(self):
     self.assertEqual(join([0, 1, 2], "glue"), "0glue1glue2")