Answer the question
In order to leave comments, you need to log in
How to extract the necessary data from the text?
I am writing a script to automate checking the validity of UTM keys (EGAIS),
the problem is to extract data from the UTM response
[
[
Version: V3
Subject: CN=Фамилия Имя Отчество, SURNAME=Фамилия, GIVENNAME=Имя Отчество, C=RU, ST=23 Регион, L=Город, STREET=ул. улица д. 00, OID.0.0.000.000.0=#00000000000000000000000000, OID.0.0.000.000.0=#00000000000000000000000000, [email protected], OID.0.0.000.000.0=#00000000000000000000000000
Signature Algorithm: 0.0.000.0.0.0.0.0, OID = 0.0.000.0.0.0.0.0
...не нужные данные...
Validity: [From: Thu Oct 10 09:45:58 MSK 2019,
To: Sat Oct 10 09:55:58 MSK 2020]
Issuer: CN="ООО \"РОГА И КОПЫТА\"", O="ООО \"РОГА И КОПЫТА\"", STREET=ул. улица д. 00, L=Город, ST=23 Регион, C=RU, OID.0.0.000.000.0=#00000000000000000000000000, OID.0.0.000.000.0=#00000000000000000000000000, [email protected]
SerialNumber: [ 00000000 00000000 0000]
...не нужные данные...
]
]
Answer the question
In order to leave comments, you need to log in
don’t use it, this “spider line” will soon overtake the miserable combed snowflakes in use, it is everywhere, really everywhere, it already twitches the eye
Something tells me that you can see such an effect on this site :) I even have such a habit: I liked the site - I'll look into the console :) Open the console, find the file that "connects" the animation, then study the code itself or look for sources on the Internet (as a rule, they are indicated in the license).
text = '''
Version: V3
Subject: CN=Фамилия Имя Отчество, SURNAME=Фамилия, GIVENNAME=Имя Отчество, C=RU, ST=23 Регион, L=Город, STREET=ул. улица д. 00, OID.0.0.000.000.0=#00000000000000000000000000, OID.0.0.000.000.0=#00000000000000000000000000, [email protected], OID.0.0.000.000.0=#00000000000000000000000000
Signature Algorithm: 0.0.000.0.0.0.0.0, OID = 0.0.000.0.0.0.0.0
...не нужные данные...
Validity: [From: Thu Oct 10 09:45:58 MSK 2019,
To: Sat Oct 10 09:55:58 MSK 2020]
Issuer: CN="ООО \"РОГА И КОПЫТА\"", O="ООО \"РОГА И КОПЫТА\"", STREET=ул. улица д. 00, L=Город, ST=23 Регион, C=RU, OID.0.0.000.000.0=#00000000000000000000000000, OID.0.0.000.000.0=#00000000000000000000000000, [email protected]
SerialNumber: [ 00000000 00000000 0000]
...не нужные данные...
'''
for line in text.split('\n'):
if 'Subject' in line:
a = [x.split('=') for x in line.split(':')[1].split(',')]
data = dict(zip([x[0].strip() for x in a], [x[1].strip() for x in a]))
print('CN> ', data['CN'])
print('SURNAME> ', data['SURNAME'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question