hi, i've tried to search any examples to understand more about how to use the urllib in python 3.1, but all the tutorials are for python 2.x
i need to do just a simple thing like getting the text (as string) and manipulate it.
the code in python 2.x would be like:
import urllib url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345' text = urllib.urlopen(url).read()
but when i tried it in python 3.1 (with urllib.request) like this:
import urllib.request url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=' current = '12345' response = urllib.request.urlopen(url+current) text = response.read() current = text[-5:] response = urllib.request.urlopen(url+current)
it gives me an error:
Can't convert 'bytes' object to str implicitly
i then look into the value of 'text' which turns out to be something like b'........' which means its a binary value.
from what i read and understand from the tutorials about urllib in python 2.x, when you do the urllib....read(), it gives you back a string.
i tried to convert the binary to string with binascii.b2a_uu(html), but the result is even more catastrophic.
can anyone please help how i can do this thing? thank you.