Fake
Fake

Reputation: 83

how regex string response from urllib2

i want Regex response from urllib2 request, when i received response i get this string

<span title="decrypted md5 hash">abc123</span>

my regex test don't work with

^ Starts with $ Ends with

here my test code

uva = re.search(r'^decrypted md5 hash.$</span>', resultado)

i got this error

SyntaxError: Non-ASCII character '\xcb' in file md5decode.py on line 13, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Upvotes: 1

Views: 76

Answers (2)

Rahul Raut
Rahul Raut

Reputation: 1518

Your code is trying to use the ASCII encoding, but the pound symbol is not an ASCII character. Try using UTF-8 encoding. You can start by putting # -*- coding: utf-8 -*- at the top of your .py file.

Upvotes: 1

Daniel Skovli
Daniel Skovli

Reputation: 495

Adding # coding: utf8 to the very top of your python script should take care of that encoding error, but at the same time, I don't think your regex is doing what you want it to be doing. :)

Upvotes: 0

Related Questions