the-honk/python/pythonchallenge.com/2 - OCR.py
2024-10-09 18:02:48 +01:00

12 lines
No EOL
298 B
Python

import urllib.request
import re
html = urllib.request.urlopen('http://www.pythonchallenge.com/pc/def/ocr.html').read().decode()
comments = re.findall('<!--(.*?)-->', html, re.DOTALL)
data = comments[-1]
count = {}
for c in data:
count[c] = count.get(c, 0) + 1
print(count) # equality is rare