View Single Post
Old 11-02-2010, 09:34 AM   #1
janvanmaar
Addict
janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.
 
Posts: 219
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
mechanize.py error when logging in to subscribed articles

I try to use the following plugin to fetch subscribed articles:
Code:
from calibre.web.feeds.news import BasicNewsRecipe

class TyzdenRecipe(BasicNewsRecipe):
    title          = u'.tyzden'
    oldest_article = 7
    max_articles_per_feed = 100
    needs_subscription    = True
    language = 'sk'

    feeds          = [(u'.tyzden - clanky z tlacenych vydani', u'http://www.tyzden.sk/rss/clanky-z-tlacenych-vydani.xml')]

    LOGIN = 'http://www.tyzden.sk/prihlasenie.html'

    def get_browser(self):
        br = BasicNewsRecipe.get_browser()
        if self.username is not None and self.password is not None:
            br.open(self.LOGIN)
            br.select_form(nr=1)
            br['user'] = self.username
            br['pass'] = self.password
            br.submit()
        return br
It gets to the right form and finds the right fields but then crashes when trying to submit the form:
Quote:
InputFormatPlugin: Recipe Input running
Traceback (most recent call last):
File "/tmp/init.py", line 48, in <module>
File "/home/kovid/build/calibre/src/calibre/utils/ipc/worker.py", line 107, in main
File "/home/kovid/build/calibre/src/calibre/gui2/convert/gui_conversion.py", line 24, in gui_convert
File "/home/kovid/build/calibre/src/calibre/ebooks/conversion/plumber.py", line 836, in run
File "/home/kovid/build/calibre/src/calibre/customize/conversion.py", line 216, in __call__
File "/home/kovid/build/calibre/src/calibre/web/feeds/input.py", line 101, in convert
File "/home/kovid/build/calibre/src/calibre/web/feeds/news.py", line 616, in __init__
File "/tmp/calibre_0.7.26_tmp_bsIqcm/calibre_0.7.26_u79lhp_recipes/recipe0.py", line 29, in get_browser
br.submit()
File "/usr/lib64/python2.6/site-packages/mechanize/_mechanize.py", line 547, in submit
File "/usr/lib64/python2.6/site-packages/mechanize/_mechanize.py", line 209, in open
File "/usr/lib64/python2.6/site-packages/mechanize/_mechanize.py", line 261, in _mech_open
mechanize._response.httperror_seek_wrapper: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Found
I don't understand why this is happening... Any idea?
I should mention that login works fine when I fill the form in a browser. I double checked that correct username and password are inputted in the scheduler also...
janvanmaar is offline   Reply With Quote