Created
May 23, 2019 08:01
-
-
Save MhmdRyhn/8da959e8c65d7ac20523c95cec022245 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from: https://stackoverflow.com/a/49207730/5600965 | |
# This requires BeautifulSoup | |
# cfemail = element.__dict__['attrs'].get('data-cfemail') | |
def get_protected_email(cfemail): | |
""" | |
** Retrieve e-mail from the protected state | |
** Arguments: | |
- cfemail: value of `data-cfemail` attribute | |
** Returns: | |
- The e-mail in plain text (as string) | |
""" | |
if not cfemail: | |
return '' | |
encoded_bytes = bytes.fromhex(cfemail) | |
email = bytes(byte ^ encoded_bytes[0] for byte in encoded_bytes[1:]).decode('utf8') | |
return email |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment