Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

中国银行信用卡 parser 无法解析 currency #18

Closed
richard1122 opened this issue Feb 5, 2025 · 8 comments
Closed

中国银行信用卡 parser 无法解析 currency #18

richard1122 opened this issue Feb 5, 2025 · 8 comments

Comments

@richard1122
Copy link
Contributor

邮件大概是这个格式:

Image

打断点发现在处理 currency_regex 时

if m := currency_regex.match(text):

tag content:

<div class="bill_card_des">
					   人民币交易明细/RMB  Transaction Detail
				   </div>

text = 人民币交易明细/RMB Transaction Detail

这个跟现在的 currency_regex 不 match


我看到现在的 currency_regex 会 match 括号之后的币种,跟我这个邮件的内容不一致。我可以发 PR 改一下,但想确认下这个例子跟你已有的内容一致吗? Thanks

@jiegec
Copy link
Owner

jiegec commented Feb 5, 2025

代码中对人民币进行了特判:

                    if "人民币交易明细" in content:
                        currency = "CNY"
                    elif m := currency_regex.match(content):
                        currency = m.group(2)

所以这个时候是不会用到 currency_regex的。但是为啥人民币没匹配上呢,可能要在代码里 print 到 stderr 看一下了。

@jiegec
Copy link
Owner

jiegec commented Feb 5, 2025

然后邮件正文直接写内容应该是比较早期的邮件吧,后来的邮件都是PDF了。我都是拿后来的PDF测的,之前的HTML版本转成PDF再导入我没试过。

@jiegec
Copy link
Owner

jiegec commented Feb 5, 2025

哦,我知道了,这段代码只处理了 PDF,没有处理 email:

代码中对人民币进行了特判:

                    if "人民币交易明细" in content:
                        currency = "CNY"
                    elif m := currency_regex.match(content):
                        currency = m.group(2)

所以这个时候是不会用到 currency_regex的。但是为啥人民币没匹配上呢,可能要在代码里 print 到 stderr 看一下了。

那我把这个逻辑复制到 email 那边,估计就可以了?

@jiegec
Copy link
Owner

jiegec commented Feb 5, 2025

试试看 commit b83a1a7,不知道是否解决了问题。

@richard1122
Copy link
Contributor Author

Thanks, 我简单试了下没问题。想问下现在主要维护的是 PDF 的版本吗?我本地有些 fix 晚点可以推上来。

@jiegec
Copy link
Owner

jiegec commented Feb 6, 2025

Thanks, 我简单试了下没问题。想问下现在主要维护的是 PDF 的版本吗?我本地有些 fix 晚点可以推上来。

对,我看中行从21年开始都是PDF了?email应该是更早的。以后还有email版的账单吗?

@richard1122
Copy link
Contributor Author

我昨天用了补发的账单,还是 EML 的

或者在中国银行手机客户端-信用卡-历史账单-选择月份-发送电子账单,从邮箱保存,获得 EML 格式的文件。

@jiegec
Copy link
Owner

jiegec commented Feb 6, 2025

我昨天用了补发的账单,还是 EML 的

或者在中国银行手机客户端-信用卡-历史账单-选择月份-发送电子账单,从邮箱保存,获得 EML 格式的文件。

原来如此,那就继续维护着吧,其实EML还更好解析一点

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants