IDEA:
Need to parse the webpage pythonchallenge.com/pc/def/ocr.html and extract the commented scrap text having loads of chars
We are supposed to find the unique characters from that text.
CODE
--------------------------------
import urllib2
r = urllib2.urlopen('http://www.pythonchallenge.com/pc/def/ocr.html')
h = r.read()
import re
o = re.match(r'.*<!--.*-->.*<!--(.*)-->.*', h, re.S)
print
d = ''
if o:
print o.group(1)
d = o.group(1)
h1 = {}
for e in d:
if e in h1:
h1[e] = h1[e] + 1
else:
h1[e] = 1
op = ''
for k in h1.keys():
if h1[k] == 1:
op = op + k
print op
---------------------------
equality should be the answer
http://www.pythonchallenge.com/pc/def/equality.html
Need to parse the webpage pythonchallenge.com/pc/def/ocr.html and extract the commented scrap text having loads of chars
We are supposed to find the unique characters from that text.
CODE
--------------------------------
import urllib2
r = urllib2.urlopen('http://www.pythonchallenge.com/pc/def/ocr.html')
h = r.read()
import re
o = re.match(r'.*<!--.*-->.*<!--(.*)-->.*', h, re.S)
d = ''
if o:
print o.group(1)
d = o.group(1)
h1 = {}
for e in d:
if e in h1:
h1[e] = h1[e] + 1
else:
h1[e] = 1
op = ''
for k in h1.keys():
if h1[k] == 1:
op = op + k
print op
---------------------------
equality should be the answer
http://www.pythonchallenge.com/pc/def/equality.html
No comments:
Post a Comment