예제 #1
0
파일: models.py 프로젝트: DarkGreising/pypo
 def fetch_article(self):
     """
     Fetches a title and a readable_article for the current url.
     It uses the scrapers module for this and only downloads the content.
     """
     dl = download(self.url, max_content_length=settings.PYPO_MAX_CONTENT_LENGTH)
     self.title, self.readable_article = parse(self, content_type=dl.content_type,
                                               text=dl.text, content=dl.content)
예제 #2
0
파일: models.py 프로젝트: stnrlgc/pypo
 def fetch_article(self):
     """
     Fetches a title and a readable_article for the current url.
     It uses the scrapers module for this and only downloads the content.
     """
     dl = download(self.url,
                   max_content_length=settings.PYPO_MAX_CONTENT_LENGTH)
     self.title, self.readable_article = parse(self,
                                               content_type=dl.content_type,
                                               text=dl.text,
                                               content=dl.content)
예제 #3
0
파일: models.py 프로젝트: buildsample/pypo
 def fetch_article(self):
     """
     Fetches a title and a readable_article for the current url.
     It uses the scrapers module for this and only downloads the content.
     """
     try:
         dl = download(self.url, max_content_length=settings.PYPO_MAX_CONTENT_LENGTH)
     except DownloadException:
         # TODO show a message that the download failed?
         self.title = self.url
         self.readable_article = None
     else:
         self.title, self.readable_article = parse(self, content_type=dl.content_type,
                                               text=dl.text, content=dl.content)
예제 #4
0
파일: test_readme.py 프로젝트: audax/pypo
def test_invalid_html(user):
    item = Item.objects.create(url='http://some_invalid_localhost', title='nothing', owner=user)
    assert (item.url, '') == parse(item, content_type='text/html', text=None)
예제 #5
0
 def test_invalid_html(self):
     item = Item.objects.create(url='http://some_invalid_localhost',
                                domain='nothing',
                                owner=User.objects.get(pk=1))
     self.assertEqual((item.url, ''),
                      parse(item, content_type='text/html', text=None))
예제 #6
0
파일: tests.py 프로젝트: DarkGreising/pypo
 def test_invalid_html(self):
     item = Item.objects.create(url='http://some_invalid_localhost', domain='nothing', owner=User.objects.get(pk=1))
     self.assertEqual((item.url, ''), parse(item, content_type='text/html', text=None))