By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,822 Members | 975 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,822 IT Pros & Developers. It's quick & easy.

Error with form

P: 7
Hello

I'm new here, but I need some help. I'm trying to do a login into the safilo website (http://www.safilonet.safilo.com/) running python code.
There is an error that I'm not capable to find where it is:

---------- run.py
Expand|Select|Wrap|Line Numbers
  1. """UPDATE SAFILO"""
  2.  
  3.         ss = SafiloSupplier(updateBrands=True)
  4.  
  5.         #ss.resetLog()
  6.         #ss.printBrands()
  7.  
  8.         brds = ss._brands
  9.  
  10.         start_at_brand = ''
  11.         print 'Brands before filtering:', len(brds)
  12.         if len(start_at_brand) > 0:
  13.             while len(brds) > 0 and brds[0]._ref != start_at_brand:
  14.                 brds.pop(0)
  15.         print 'Brands after filtering:', len(brds)
  16.         #sys.exit(0)
  17.  
  18.         #ss.clearAllModelFromSql()
  19.  
  20.         for b in brds:
  21.             ss.addToLog('** BRAND %s... **' % b._ref, True)
  22.  
  23.             print '*** Updating catalog... ***'
  24.             ss.updateCatalog(b._ref)
  25.  
  26.             print '*** Expanding models... ***'
  27.             ss.expandModels(b._ref)
  28.  
  29. ----------- Supplier.py
  30.  
  31. class SafiloSupplier(Supplier):
  32.     '''
  33.     100% faulty HTML webscrapping client for Safilo supplier.
  34.     Uses hand-made MiniTidy class for converting HTML to valid XML for further parsing.
  35.     '''
  36.  
  37.     def __init__(self, updateBrands=False, login=True):
  38.         Supplier.__init__(self)
  39.  
  40.         self._name = 'Safilo'
  41.         self._username = '******' 
  42.         self._password = '******' 
  43.         self._baseUrl = 'http://www.safilonet.safilo.com'
  44.         self._ignoreBrandsWithRef = ['BLU', 'SAF']
  45.         self._root += 'safilo\\'
  46.         self._brandsPC = PersistLite(instance=Brand(), path=self._root + 'brands\\brands.sqlite')
  47.         self.last_logged_in = None
  48.  
  49.         if login: self.login()
  50.  
  51.         if updateBrands:
  52.             self.updateBrands()    # also saves
  53.         else:
  54.             self.loadBrands()
  55.  
  56.         self.filterBrands()
  57.  
  58.  
  59.     def check_login(self):
  60.         n = datetime.datetime.now()
  61.         dt = n - self.last_logged_in
  62.         if dt.seconds > 120:
  63.             print 'Logged in for %d seconds. Logging in again...' % dt.seconds
  64.             self.login()
  65.  
  66.     ##webapp/commerce/safilo/jsp/logon.jsp
  67.  
  68.     def login(self):
  69.         url = self._baseUrl + '/webapp/commerce/logon'
  70.         self._br.open(url, timeout=30.0)
  71.         self._br.select_form('logon')
  72.         self._br.form['login'] = self._username
  73.         self._br.form['password'] = self._password
  74.         self._br.submit()
  75.  
  76.         if self._verbose: print 'Login successful.\n'
  77.  
  78.         self.last_logged_in = datetime.datetime.now()
  79.  
  80. There is more code in both files, but i think the error is somewhere on this peace of code.
  81.  
  82. The error presented is:
  83.  
  84. Traceback (most recent call last):
  85.   File "E:\billy\Projects\GlassInteg\trunk\src\run.py", line 89, in <module>
  86.     go()
  87.   File "E:\billy\Projects\GlassInteg\trunk\src\run.py", line 39, in go
  88.     ss = SafiloSupplier(updateBrands=True)
  89.   File "E:\billy\Projects\GlassInteg\trunk\src\GlassInteg\Supplier.py", line 280, in __init__
  90.     if login: self.login()
  91.   File "E:\billy\Projects\GlassInteg\trunk\src\GlassInteg\Supplier.py", line 302, in login
  92.     self._br.select_form('logon')
  93.   File "build\bdist.win32\egg\mechanize\_mechanize.py", line 524, in select_form
  94. mechanize._mechanize.FormNotFoundError: no form matching name 'logon'
Can you please help me?
Sep 19 '12 #1

✓ answered by Rabbit

Which page are you getting that from? Because that form may exist on http://www.safilonet.safilo.com but that's not where you're trying to login from. In your code, you're trying to login from http://www.safilonet.safilo.com/webapp/commerce/logon and that page has no such form.

Share this Question
Share on Google+
5 Replies

Rabbit
Expert Mod 10K+
P: 12,441
It would help to know what that error message is.
Oct 9 '12 #2

P: 7
@Rabbit The error message is on the line 82. I haven't still solved this problem! I can't understand what's going on...
Oct 9 '12 #3

Rabbit
Expert Mod 10K+
P: 12,441
It sounds like a pretty clear error message. There's no form on that page named logon.
Oct 9 '12 #4

P: 7
There is a form named logon,

Take a look at this source code:

Expand|Select|Wrap|Line Numbers
  1. <form action="https://www.safilonet.safilo.com/webapp/commerce/logon" method="post" target="_top" name="logon" onsubmit="return checkFields();" enctype="application/x-www-form-urlencoded">
Oct 9 '12 #5

Rabbit
Expert Mod 10K+
P: 12,441
Which page are you getting that from? Because that form may exist on http://www.safilonet.safilo.com but that's not where you're trying to login from. In your code, you're trying to login from http://www.safilonet.safilo.com/webapp/commerce/logon and that page has no such form.
Oct 9 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.