1

I am trying to parse data from website and I am getting an error. Here's my python code

import urllib.request
import re

url = "http://ihned.cz"

req = urllib.request.Request(url)
resp = urllib.request.urlopen(req)
respData = resp.read().decode('utf-8')
#print(respData) #html kód

authors = re.findall(r'data-author="(.*?)"', str(respData))

for author in authors:
    print(authors)

And here's the error.

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 368: invalid continuation byte

Can you please help me? Thank you.

1 Answer 1

2

The source of that website says charset="windows-1250". Try decode('windows-1250').

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.