The HTML page containing the key and some \n character .I need to use only key block i.e from -----BEGIN PGP PUBLIC KEY BLOCK----- to -----END PGP PUBLIC KEY BLOCK----- and after putting extracting key in a file can i pass it in any function....
A:
in it's simpliest form
import re
clean = re.sub("</?[^\W].{0,10}?>|\n|\r\n", "", your_html) #remove tags and newlines
key = re.search(r'BEGIN PGP PUBLIC KEY BLOCK.+?END PGP PUBLIC KEY BLOCK', clean)
or if you don't need BEGIN PGP ... BLOCK
and END PGP ... BLOCK
:
key = re.search(r'BEGIN PGP PUBLIC KEY BLOCK----(.+?)----END PGP PUBLIC KEY BLOCK',clean)
is this what you're after? (I don't have python right here to check it, but I hope it's OK)
kurczak
2009-08-31 09:57:49