R
R
rodion_ilnitskiy2022-04-08 12:20:10
Python
rodion_ilnitskiy, 2022-04-08 12:20:10

How to parse text with email-protected?

There is this HTML code:

<td>
OC[<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e9aaa9a1">[email&#160;protected]</a>](OC(CCCCCCCCCCCCC)=O)COC(CCCCCCCCCCCCC)=O
</td>

You need to parse the text with python scrapy so that the result looks like on the site:
OC(OC(CCCCCCCCCCCCC)=O)COC(CCCCCCCCCCCCC)=O
However, the result is always different:
['OC[', '](OC (CCCCCCCCCCCC)=O)COC(CCCCCCCCCCCCCC)=O']
How to solve this problem?
Here is the python scrapy code:
response.xpath('//td[contains(text(),"Canonical SMILES")]/following::td[1]/text()').extract()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ramis, 2022-04-08
@rodion_ilnitskiy

Have you tried google, I tried and found it.

def decode(g):
    r = int(g[:2],16)
    email = ''.join([chr(int(g[i:i+2], 16) ^ r) for i in range(2, len(g), 2)])
    return email

print(decode('e9aaa9a1'))

#[email protected]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question