Order it now! Amazon prioritizes orders on a first come, first served basis.


View Full Version : Parser can't identify form used for user/pass


Solari
03-01-2009, 01:23 AM
Greetings,

I am trying to be able to login into my Stratfor paid account to download stories to my Kindle. For whatever reason it can't identify the form name on either http://www.stratfor.com or http://www.stratfor.com/user to login with.

Can anyone help?

Thanks,
Ray

Error:

Job: **Fetch news from Stratfor**
**tuple**: ('FormNotFoundError', u"no form matching name 'form_id'")
**Traceback**:
Traceback (most recent call last):
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/parallel.py", line 957, in worker
result = work(client_socket, func, args, kwdargs)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/parallel.py", line 915, in work
res = func(*args, **kargs)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/ebooks/mobi/from_feeds.py", line 69, in main
convert(opts, recipe_arg, notification=notification)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/ebooks/mobi/from_feeds.py", line 42, in convert
recipe = run_recipe(opts, recipe_arg, parser, notification=notification)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/web/feeds/main.py", line 148, in run_recipe
recipe = recipe(opts, parser, notification)
File "calibre/web/feeds/news.pyo", line 481, in __init__
File "/var/folders/Rj/RjcFHDS5HvWw9Jm-ZeDZck+++TI/-Tmp-/calibre_0.4.141_EYtRKv_recipes/recipe0.py", line 14, in get_browser
File "mechanize/_mechanize.pyo", line 530, in select_form
FormNotFoundError: no form matching name 'form_id'

**Log**:
('FormNotFoundError', u"no form matching name 'form_id'")
Traceback (most recent call last):
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/parallel.py", line 957, in worker
result = work(client_socket, func, args, kwdargs)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/parallel.py", line 915, in work
res = func(*args, **kargs)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/ebooks/mobi/from_feeds.py", line 69, in main
convert(opts, recipe_arg, notification=notification)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/ebooks/mobi/from_feeds.py", line 42, in convert
recipe = run_recipe(opts, recipe_arg, parser, notification=notification)
File "/Applications/calibre.app/Contents/console.app/Contents/Resources/lib/python2.6/site-packages.zip/calibre/web/feeds/main.py", line 148, in run_recipe
recipe = recipe(opts, parser, notification)
File "calibre/web/feeds/news.pyo", line 481, in __init__
File "/var/folders/Rj/RjcFHDS5HvWw9Jm-ZeDZck+++TI/-Tmp-/calibre_0.4.141_EYtRKv_recipes/recipe0.py", line 14, in get_browser
File "mechanize/_mechanize.pyo", line 530, in select_form
FormNotFoundError: no form matching name 'form_id'

Recipe used:

class AdvancedUserRecipe1235882735(BasicNewsRecipe):
title = u'Stratfor'
needs_subscription = True
oldest_article = 1
max_articles_per_feed = 100

def get_browser(self):
br = BasicNewsRecipe.get_browser()
if self.username is not None and self.password is not None:
br.open('http://www.stratfor.com/')
br.select_form(name='form_id')
br['name'] = self.username
br['pass'] = self.password
br.submit()
return br

feeds = [(u'Australia/Ocenia', u'https://www.stratfor.com/user/342290/feed/22419/32ab9ee40cc123deccf8e7725f969b9ad6244fda'), (u'Economics/Trade', u'https://www.stratfor.com/user/342290/feed/22376/dc312596cb508fa9bb064338b4a323da07282b64')]

Solari
03-01-2009, 05:31 PM
Anyone able to help out here? Thanks.

Ray

kiklop74
03-01-2009, 05:51 PM
Your form name is incorrect which is clearly visible from your error log:


**Log**:
('FormNotFoundError', u"no form matching name 'form_id'")


The login form on stratfor.com does not have attribute name so you can not use that form of select_form method. You should use select by order number:


br.select_form(nr=1)


Test the value of nr until you get it working.

Solari
03-01-2009, 08:04 PM
Thanks! I got it working, but had to start with 0 instead of 1, thinking in computer terms. ;) That did the trick.

Thanks,
Ray