예제 #1
0
    def _fetch_article(self, url, dir_, f, a, num_of_feeds):
        br = self.browser
        if self.get_browser.im_func is BasicNewsRecipe.get_browser.im_func:
            # We are using the default get_browser, which means no need to
            # clone
            br = BasicNewsRecipe.get_browser(self)
        else:
            br = self.clone_browser(self.browser)
        self.web2disk_options.browser = br
        # ============== Here is the only change =================
        fetcher = RichRecursiveFetcher(self.web2disk_options, self.log,
                self.image_map, self.css_map,
                (url, f, a, num_of_feeds),
                image_formats=[PngFormat(), GifFormat(), JpegFormat()])
        # ========================================================
        fetcher.browser = br
        fetcher.base_dir = dir_
        fetcher.current_dir = dir_
        fetcher.show_progress = False
        fetcher.image_url_processor = self.image_url_processor
        res, path, failures = fetcher.start_fetch(url), fetcher.downloaded_paths, fetcher.failed_links
        if not res or not os.path.exists(res):
            msg = _('Could not fetch article.') + ' '
            if self.debug:
                msg += _('The debug traceback is available earlier in this log')
            else:
                msg += _('Run with -vv to see the reason')
            raise Exception(msg)

        return res, path, failures
예제 #2
0
    def _fetch_article(self, url, dir_, f, a, num_of_feeds):
        br = self.browser
        if self.get_browser.im_func is BasicNewsRecipe.get_browser.im_func:
            # We are using the default get_browser, which means no need to
            # clone
            br = BasicNewsRecipe.get_browser(self)
        else:
            br = self.clone_browser(self.browser)
        self.web2disk_options.browser = br
        # ============== Here is the only change =================
        fetcher = RichRecursiveFetcher(
            self.web2disk_options,
            self.log,
            self.image_map,
            self.css_map, (url, f, a, num_of_feeds),
            image_formats=[PngFormat(), GifFormat(),
                           JpegFormat()])
        # ========================================================
        fetcher.browser = br
        fetcher.base_dir = dir_
        fetcher.current_dir = dir_
        fetcher.show_progress = False
        fetcher.image_url_processor = self.image_url_processor
        res, path, failures = fetcher.start_fetch(
            url), fetcher.downloaded_paths, fetcher.failed_links
        if not res or not os.path.exists(res):
            msg = _('Could not fetch article.') + ' '
            if self.debug:
                msg += _(
                    'The debug traceback is available earlier in this log')
            else:
                msg += _('Run with -vv to see the reason')
            raise Exception(msg)

        return res, path, failures
예제 #3
0
 def get_browser(self):
     br = BasicNewsRecipe.get_browser()
     if self.username is not None and self.password is not None:
         br.open('http://www.nytimes.com/auth/login')
         br.form = br.forms().next()
         br['userid']   = self.username
         br['password'] = self.password
         raw = br.submit().read()
         if 'Please try again' in raw:
             raise Exception('Your username and password are incorrect')
     return br
예제 #4
0
 def get_browser(self):
     br = BasicNewsRecipe.get_browser(self)
     if self.username and self.password:
         if self.appURL == 'http://app.inthepoche.com':
             br.open(self.appURL + '/u/' + self.username)
         else:
             br.open(self.appURL)
         br.select_form(name='loginform')
         br['login'] = self.username
         br['password'] = self.password
         br.submit()
     return br
예제 #5
0
 def get_cover_url(self):
     cover = None
     st = time.localtime()
     year = str(st.tm_year)
     month = "%.2d" % st.tm_mon
     day = "%.2d" % st.tm_mday
     cover = 'http://graphics8.nytimes.com/images/' + year + '/' +  month +'/' + day +'/nytfrontpage/scan.jpg'
     br = BasicNewsRecipe.get_browser()
     try:
         br.open(cover)
     except:
         self.log("\nCover unavailable")
         cover = None
     return cover
예제 #6
0
 def get_browser(self):
     br = BasicNewsRecipe.get_browser(self)
     self.authentify_to_poche(br)
     return br
예제 #7
0
 def get_browser(self):
     br = BasicNewsRecipe.get_browser(self)
     self.authentify_to_poche(br)
     return br