Email 如何使用JSOUP解析[受电子邮件保护的]数据
有没有办法通过JSOUP解析受以下代码保护的电子邮件地址:Email 如何使用JSOUP解析[受电子邮件保护的]数据,email,parsing,jsoup,Email,Parsing,Jsoup,有没有办法通过JSOUP解析受以下代码保护的电子邮件地址: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="29484e4a404a4c50404469484e4a404a4c504044074a4644">[email protected]</a> 使用标准元素进行解析时。选择(“.email”).text()返回[受电子邮件保护]。 我尝试用谷歌搜
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="29484e4a404a4c50404469484e4a404a4c504044074a4644">[email protected]</a>
使用标准元素进行解析时。选择(“.email”).text()代码>返回[受电子邮件保护]
。
我尝试用谷歌搜索,但发现了很多不相关的信息。电子邮件地址是通过将电子邮件地址中的每个字符与随机生成的第一个字节进行XORing来“加密”的。将十六进制字符串解码为字节数组,并将所有字节与第一个字节异或以解密地址
例如(在Python中):
以下是Java中的相同登录:
public static String convertToEmail(String hex) {
try {
byte[] decoded = Hex.decodeHex(hex);
byte firstByte = decoded[0];
byte[] newBytes = new byte[decoded.length - 1];
for (int i = 0; i < decoded.length; i++) {
byte result = (byte) (decoded[i] ^ firstByte);
if (i == 0) {
continue;
}
newBytes[i - 1] = result;
}
return new String(newBytes);
} catch (DecoderException e) {
e.printStackTrace();
}
return null;
}
要获取加密的电子邮件,请使用元素。选择(“.email”).attr(“data cfemail”)
非常感谢。我已经在中实现了它,它工作得非常完美!
public static String convertToEmail(String hex) {
try {
byte[] decoded = Hex.decodeHex(hex);
byte firstByte = decoded[0];
byte[] newBytes = new byte[decoded.length - 1];
for (int i = 0; i < decoded.length; i++) {
byte result = (byte) (decoded[i] ^ firstByte);
if (i == 0) {
continue;
}
newBytes[i - 1] = result;
}
return new String(newBytes);
} catch (DecoderException e) {
e.printStackTrace();
}
return null;
}
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>