예제 #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
파일: tests.py 프로젝트: AgentK1729/django
 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")