[L2]: The symbols into words

4,450 views
Skip to first unread message

Nathster Slvester

unread,
May 19, 2016, 1:52:45 AM5/19/16
to Python Challenge
Hey everyone,

I was able to get the grab the source code for the webpage, but I have really no clue what to do with the symbols. My current code is:

from urllib.request import urlopen
import string


a = request.read()
print(a.splitlines())

Does anyone know of a next step?

Nathster Slvester

unread,
May 21, 2016, 4:25:53 PM5/21/16
to Python Challenge
Edit:

from urllib.request import urlopen
import re


a = request.read()

b = a.decode("utf-8")

d = re.findall('[a-z]', b)


e = ''.join(d)

print (e)
input()

I changed my code to this and it says I need to pick up rare characters. Any idea on how to do this?

jseb

unread,
May 26, 2016, 9:09:22 AM5/26/16
to Python Challenge
Just take a look at the source code of the web page.

Vikram Panigrahi

unread,
Sep 7, 2019, 3:26:44 AM9/7/19
to Python Challenge
you need to apply regex on the mess, i.e. line 38-1257 and not the entire page source.

data = request.readlines()
encrypted_message = map(lambda bytes: bytes.decode("utf-8"), data[37:1257])
rare_chars = re.findall('[a-zA-Z]+', ''.join(encrypted_message))
message = ''.join(rare_chars)

Michael Russell

unread,
Sep 7, 2019, 9:26:25 AM9/7/19
to Python Challenge
Yeah don't read the whole HTML, just that one comment. Then it says to find the rare characters so do that. Count how many times each character occurs and then see which ones are rare.
Reply all
Reply to author
Forward
0 new messages