This is my example script:
import urllib2, re
response = urllib2.urlopen('http://domain.tld/file')
data = response.read() # Normally displays "the emoticon <3 is blah blah"
pattern = re.search('(the emoticon )(.*)( is blah blah)', data)
result = pattern.group(2) # result should contain "<3" now
print 'The result is ' + result # prints "<3" because not encoded
As you can see, I am obtaining a page and trying to get a string out of it, but it isn't encoded correctly as I am not sure what to add to this script o make the end result correct. Could anyone point out what I am doing wrong?