add proxy for the first part and try to develop the second part

This commit is contained in:
Pierre Geeraert
2025-12-03 12:08:56 +00:00
parent 6c34d510e5
commit 460f18d85a
1095 changed files with 358799 additions and 5 deletions
@@ -0,0 +1,26 @@
import re
def striphtml(data):
p = re.compile(r'<.*?>')
return p.sub('', data)
def validate(string):
import requests
payload = {'snip': string}
ret = requests.post('http://severinghaus.org/projects/icv/', data=payload)
if 'Sorry, your calendar could not be parsed.' in ret.text:
i = ret.text.index('<div class="parse-error">')
j = ret.text[i:].index('</div>')
usefull = ret.text[i:i + j]
usefull_clean = striphtml(usefull)
lines = usefull_clean.split('\n')
lines_clean = map(lambda x: x.strip(), lines)
lines_no_empty = filter(lambda x: x != '', lines_clean)
return '\n'.join(lines_no_empty)
elif 'Congratulations; your calendar validated!' in ret.text:
return True
else:
return None