mirror of
https://github.com/kemayo/leech
synced 2025-12-06 16:33:16 +01:00
Grab the much more-pythonic CF email decode from #37
This commit is contained in:
parent
966bd2c120
commit
bf315d06fe
1 changed files with 2 additions and 3 deletions
|
|
@ -201,9 +201,8 @@ class Site:
|
||||||
# <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85d5eaecebf1dac8e0dac5">[email protected]</a>_The_Sky
|
# <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85d5eaecebf1dac8e0dac5">[email protected]</a>_The_Sky
|
||||||
for a in contents.find_all('a', class_='__cf_email__', href='/cdn-cgi/l/email-protection'):
|
for a in contents.find_all('a', class_='__cf_email__', href='/cdn-cgi/l/email-protection'):
|
||||||
# See: https://usamaejaz.com/cloudflare-email-decoding/
|
# See: https://usamaejaz.com/cloudflare-email-decoding/
|
||||||
encoded = a['data-cfemail']
|
enc = bytes.fromhex(a['data-cfemail'])
|
||||||
r = int(encoded[:2], 16)
|
email = bytes([c ^ enc[0] for c in enc[1:]]).decode('utf8')
|
||||||
email = ''.join([chr(int(encoded[i:i+2], 16) ^ r) for i in range(2, len(encoded), 2)])
|
|
||||||
a.insert_before(email)
|
a.insert_before(email)
|
||||||
a.decompose()
|
a.decompose()
|
||||||
return contents
|
return contents
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue