简体   繁体   English

Javascript:在确认电子邮件中找到确认链接

[英]Javascript: find confirmation link in confirmation email

I am trying to scan the body of an email for a confirmation link. 我正在尝试扫描电子邮件正文以获取确认链接。 I am not sure how to find the right link though. 我不确定如何找到正确的链接。

All interesting e-mails have their link inside the href attribute of an a element, the link sometimes contains one or more of some keywords like "register", "validate", "click", "uid"... and some form of ID. 所有有趣的电子邮件在元素的href属性中都有其链接,该链接有时包含一个或多个某些关键字,例如“ register”,“ validate”,“ click”,“ uid” ...和某种形式的ID。 Sadly all don't have those keywords and the IDs also have many different ways they can look. 遗憾的是,所有人都没有这些关键字,ID的外观也有许多不同的方式。

Do you have any ideas how you can find the right link, maybe something I missed? 您是否有任何想法如何找到正确的链接,也许是我错过的东西?

While there is no standard for how confirmation links in emails are formatted and it's almost impossible to detect all of them with 100% accuracy, but you can still cover a whole lot. 虽然没有标准格式确定电子邮件中确认链接的格式,并且几乎不可能以100%的准确性检测所有这些链接,但是您仍然可以涵盖很多内容。

I think you're moving in the right direction. 我认为您正在朝着正确的方向前进。 You can also look for words, if any, inside the anchor tags like; 您也可以在锚标记中查找单词(如果有),例如; 'Confirm you email,' 'Click here to confirm.' “确认您的电子邮件”,“单击此处进行确认”。 Also the words before and after the anchor tags themselves. 锚之前和之后的单词也标记自己。 Don't just analyse the hrefs apart from their context. 不要只分析href的上下文。

You can go a bit further and open the links that don't fit these criteria then look for certain helping keywords. 您可以走得更远,打开不符合这些条件的链接,然后寻找某些帮助关键字。 It's a bit risky, though, as some confirmation links expire after they're opened. 但是,这有些冒险,因为某些确认链接在打开后会过期。 So keep that in mind. 所以记住这一点。

A bit advanced approach (and a bit out there TBH) you can apply, if none of the links in an email are identified as confirmation links, could be taking a screenshot from the email itself and someone selects where the confirmation link is then do some analysis on the position of the click then select the corresponding element and get your link. 如果电子邮件中没有任何链接被标识为确认链接,则可以应用一种高级方法(还有TBH),可以从电子邮件本身获取屏幕截图,然后有人选择确认链接的位置,然后执行一些操作。分析点击的位置,然后选择相应的元素并获取链接。 I'm not kidding! 我不是在开玩笑! you can do it using Puppeteer in a relatively easy way! 您可以以相对简单的方式使用Puppeteer

Of course you can always use machine learning but you don't wanna go there. 当然,您始终可以使用机器学习,但您不想去那里。

And that's it, I think. 我想就是这样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM