1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-06 08:22:56 +01:00

Grab the much more-pythonic CF email decode from #37

This commit is contained in:
David Lynch 2021-03-27 11:20:01 -05:00
parent 966bd2c120
commit bf315d06fe

View file

@ -201,9 +201,8 @@ class Site:
# <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85d5eaecebf1dac8e0dac5">[email&#160;protected]</a>_The_Sky # <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85d5eaecebf1dac8e0dac5">[email&#160;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