gpt4 book ai didi

python - 如何在使用 python 进行网络抓取时解码 [email\xa0protected]

转载 作者:行者123 更新时间:2023-12-02 16:52:13 24 4
gpt4 key购买 nike

当我尝试使用 python lxml.html 从下面的标签中提取邮件 ID 时,它显示 [email\xa0protected],任何人都可以帮助我解码它。

<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4420366a373021283e2136042921202d27212a30262520212a6a272b29">[email&#160;protected]</a>

最佳答案

最后,我找到了答案:

fp = '4420366a373021283e2136042921202d27212a30262520212a6a272b29' # taken from data-cfemail html attribut which holds encrypted email

def deCFEmail(fp):
try:
r = int(fp[:2],16)
email = ''.join([chr(int(fp[i:i+2], 16) ^ r) for i in range(2, len(fp), 2)])
return email
except (ValueError):
pass

使用上面的代码,我们可以将 CloudFare 的 base58 值解码为文本。

例子:

s = '4420366a373021283e2136042921202d27212a30262520212a6a272b29'

print(deCFEmail(s))

关于python - 如何在使用 python 进行网络抓取时解码 [email\xa0protected],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58103525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com