表单错误
你好
我是新来的,但我需要一些帮助。我正在尝试登录Safilo网站(
Http://www.safilonet.safilo.com/
)运行PYTHON代码。
有一个错误,我无法找到它在哪里:
选择 | 换行 | 行号
- """UPDATE SAFILO"""
- ss = SafiloSupplier(updateBrands=True)
- #ss.resetLog()
- #ss.printBrands()
- brds = ss._brands
- start_at_brand = ''
- print 'Brands before filtering:', len(brds)
- if len(start_at_brand) > 0:
- while len(brds) > 0 and brds[0]._ref != start_at_brand:
- brds.pop(0)
- print 'Brands after filtering:', len(brds)
- #sys.exit(0)
- #ss.clearAllModelFromSql()
- for b in brds:
- ss.addToLog('** BRAND %s... **' % b._ref, True)
- print '*** Updating catalog... ***'
- ss.updateCatalog(b._ref)
- print '*** Expanding models... ***'
- ss.expandModels(b._ref)
- ----------- Supplier.py
- class SafiloSupplier(Supplier):
- '''
- 100% faulty HTML webscrapping client for Safilo supplier.
- Uses hand-made MiniTidy class for converting HTML to valid XML for further parsing.
- '''
- def __init__(self, updateBrands=False, login=True):
- Supplier.__init__(self)
- self._name = 'Safilo'
- self._username = '******'
- self._password = '******'
- self._baseUrl = 'http://www.safilonet.safilo.com'
- self._ignoreBrandsWithRef = ['BLU', 'SAF']
- self._root += 'safilo\\'
- self._brandsPC = PersistLite(instance=Brand(), path=self._root + 'brands\\brands.sqlite')
- self.last_logged_in = None
- if login: self.login()
- if updateBrands:
- self.updateBrands() # also saves
- else:
- self.loadBrands()
- self.filterBrands()
- def check_login(self):
- n = datetime.datetime.now()
- dt = n - self.last_logged_in
- if dt.seconds > 120:
- print 'Logged in for %d seconds. Logging in again...' % dt.seconds
- self.login()
- ##webapp/commerce/safilo/jsp/logon.jsp
- def login(self):
- url = self._baseUrl + '/webapp/commerce/logon'
- self._br.open(url, timeout=30.0)
- self._br.select_form('logon')
- self._br.form['login'] = self._username
- self._br.form['password'] = self._password
- self._br.submit()
- if self._verbose: print 'Login successful.\n'
- self.last_logged_in = datetime.datetime.now()
- There is more code in both files, but i think the error is somewhere on this peace of code.
- The error presented is:
- Traceback (most recent call last):
- File "E:\billy\Projects\GlassInteg\trunk\src\run.py", line 89, in <module>
- go()
- File "E:\billy\Projects\GlassInteg\trunk\src\run.py", line 39, in go
- ss = SafiloSupplier(updateBrands=True)
- File "E:\billy\Projects\GlassInteg\trunk\src\GlassInteg\Supplier.py", line 280, in __init__
- if login: self.login()
- File "E:\billy\Projects\GlassInteg\trunk\src\GlassInteg\Supplier.py", line 302, in login
- self._br.select_form('logon')
- File "build\bdist.win32\egg\mechanize\_mechanize.py", line 524, in select_form
- mechanize._mechanize.FormNotFoundError: no form matching name 'logon'
你能帮帮我吗?