예제 #1
0
    def test_get_story_details(self):
        scraper = NPRAPIScraper()
        url = 'http://www.npr.org/2016/04/07/473293026/what-keeps-election-officials-up-at-night-fear-of-long-lines-at-the-polls'
        details = scraper.get_story_details(url)

        self.assertEqual(details['date'].date(), date(2016, 04, 07))
        self.assertEqual(details['image'], u'https://media.npr.org/assets/img/2016/04/06/gettyimages-513187994_wide-2d1e9d8e5ed0ccd424c01ff0dbb2906ebe91a1ea.jpg?s=12')
        self.assertEqual(details['title'], 'What Keeps Election Officials Up At Night? Fear Of Long Lines At The Polls')
예제 #2
0
    def test_get_story_details(self):
        scraper = NPRAPIScraper()
        url = 'http://www.npr.org/2016/04/07/473293026/what-keeps-election-officials-up-at-night-fear-of-long-lines-at-the-polls'
        details = scraper.get_story_details(url)

        self.assertEqual(details['date'].date(), date(2016, 04, 07))
        self.assertEqual(
            details['image'],
            u'https://media.npr.org/assets/img/2016/04/06/gettyimages-513187994_wide-2d1e9d8e5ed0ccd424c01ff0dbb2906ebe91a1ea.jpg?s=12'
        )
        self.assertEqual(
            details['title'],
            'What Keeps Election Officials Up At Night? Fear Of Long Lines At The Polls'
        )
예제 #3
0
from oauth import get_document
import os
from peewee import IntegrityError
import pytz
import time

import app_config
from util.models import Story
from scrapers.npr_api import NPRAPIScraper
from scrapers.screenshot import Screenshotter

logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

npr_api_scraper = NPRAPIScraper()
screenshotter = Screenshotter()

POCKY_TRACKER = os.environ.get('POCKY_SHEET')


class PockyScraper:
    """
    From https://github.com/tarbell-project/tarbell/blob/1.0.5/tarbell/app.py#L251
    """
    def __init__(self, source):
        self.source = source

    @staticmethod
    def parse_date(value):
        """
예제 #4
0
 def test_get_story_id(self):
     scraper = NPRAPIScraper()
     url = 'http://www.npr.org/2016/04/07/473293026/what-keeps-election-officials-up-at-night-fear-of-long-lines-at-the-polls'
     story_id = scraper.get_story_id(url)
     self.assertEqual(story_id, '473293026')
예제 #5
0
 def test_get_story_id(self):
     scraper = NPRAPIScraper()
     url = 'http://www.npr.org/2016/04/07/473293026/what-keeps-election-officials-up-at-night-fear-of-long-lines-at-the-polls'
     story_id = scraper.get_story_id(url)
     self.assertEqual(story_id, '473293026')