id with hash function
This commit is contained in:
parent
bbf3db6c01
commit
f24a454677
2 changed files with 12 additions and 6 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
from .pages import AccountsList, LoginPage, LoginPage2, \
|
from .pages import AccountsList, LoginPage, LoginPage2, \
|
||||||
|
|
@ -99,7 +99,11 @@ class Ing(BaseBrowser):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
while 1:
|
while 1:
|
||||||
|
hashlist = []
|
||||||
for transaction in self.page.get_transactions():
|
for transaction in self.page.get_transactions():
|
||||||
|
while transaction.id in hashlist:
|
||||||
|
transaction.id = hashlib.md5(transaction.id + "1")
|
||||||
|
hashlist.append(transaction.id)
|
||||||
yield transaction
|
yield transaction
|
||||||
if self.page.islast():
|
if self.page.islast():
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
@ -45,19 +46,20 @@ class AccountHistory(BasePage):
|
||||||
|
|
||||||
def get_transactions(self):
|
def get_transactions(self):
|
||||||
table = self.document.findall('//tbody')[0]
|
table = self.document.findall('//tbody')[0]
|
||||||
i = 1
|
|
||||||
for tr in table.xpath('tr'):
|
for tr in table.xpath('tr'):
|
||||||
id = i
|
|
||||||
op = Transaction(id)
|
|
||||||
textdate = tr.find('td[@class="op_date"]').text_content()
|
textdate = tr.find('td[@class="op_date"]').text_content()
|
||||||
textraw = tr.find('td[@class="op_label"]').text_content()
|
textraw = tr.find('td[@class="op_label"]').text_content()
|
||||||
|
# The id will be rewrite
|
||||||
|
op = Transaction(1)
|
||||||
|
amount = op.clean_amount(tr.find('td[@class="op_amount"]').text_content())
|
||||||
|
id = hashlib.md5(textdate + textraw.encode('utf-8') + amount.encode('utf-8')).hexdigest()
|
||||||
|
op.id = id
|
||||||
op.parse(date = date(*reversed([int(x) for x in textdate.split('/')])),
|
op.parse(date = date(*reversed([int(x) for x in textdate.split('/')])),
|
||||||
raw = textraw)
|
raw = textraw)
|
||||||
# force the use of website category
|
# force the use of website category
|
||||||
op.category = unicode(tr.find('td[@class="op_type"]').text)
|
op.category = unicode(tr.find('td[@class="op_type"]').text)
|
||||||
|
|
||||||
op.amount = Decimal(op.clean_amount(tr.find('td[@class="op_amount"]').text_content()))
|
op.amount = Decimal(amount)
|
||||||
i += 1
|
|
||||||
|
|
||||||
yield op
|
yield op
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue