View Single Post
Old 03-05-2012, 08:50 PM   #11
cornfieldcraig
Member
cornfieldcraig began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Sep 2011
Location: Chicago, Illinois, USA
Device: Nook Simple Touch
Thanks anyway, Kovid. The only reason I can think of that you're not seeing the problem is that it has something to do with a cookie, that is, if calibre's browser supports them. Once the first countdown expires in the browser, subsequent pages do not have the countdown timer.

I think if there were a way to go to the URL associated with location.href (if present in the page source), it would work. There's current skip_ad_pages function, which you added a few months ago to skip a very similar countdown timer, looks like it would be close to fixing the problem. What has changed is that before, the javascript displayed the text, "click here to continue to article"; whereas now it displays just the numbers (18 to 0) in the countdown, so the text it displays is no longer unique enough to search on.

current skip_ad_pages function

Code:
    def skip_ad_pages(self, soup):
        text = soup.find(text='click here to continue to article')
        if text:
            a = text.parent
            url = a.get('href')
            if url:
                return self.index_to_soup(url, raw=True)
New Javascript Countdown Code

Code:
<script type="text/javascript">
           $(document).ready(function(){
               doCountdown(18000/1000);
			   
setTimeout( 'location.href = \'http://www.chicagotribune.com/news/chi-shootings-in-washington-park-englewood-leave-1-dead-1-wounded-20120302,0,4578641.story?track=rss\'',18000);

           });

           function doCountdown(countdownTime) {
               countdownRemaining = countdownTime - 1;
               if(countdownRemaining > 0) {
                   $("#timeCountdown").text(countdownRemaining);
                   setTimeout("doCountdown(countdownRemaining);", 1000);
               }
           };



</script>
cornfieldcraig is offline   Reply With Quote