Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:48:07+00:00 2026-06-07T17:48:07+00:00

I have a Python code that tries to read RSS sources written in Cyrillic

  • 0

I have a Python code that tries to read RSS sources written in Cyrillic letters (for example Russian). This is the code that I use:

import feedparser
from urllib2 import Request, urlopen

d=feedparser.parse(source_url)

# Make a loop over the entries of the RSS feed.
for e in d.entries:
    # Get the title of the news.
    title = e.title
    title = title.replace(' ','%20')
    title = title.encode('utf-8')

    # Get the URL of the entry.
    url = e.link
    url = url.encode('utf-8')


    # Make the request. 
    address = 'http://example.org/save_link.php?title=' + title + '&source=' + source_name + '&url=' + url

    # Submit the link.
    req = Request(address)
    f = urlopen(req)

I use encode('utf-8') since the titles are given in Cyrillic letters and it works fine. An example of the RSS source is here. The problem appears when I try to read the list of the RSS sources from another URL. In more details, there is a web-page that contains a list of RSS sources (URL of the sources as well as their names given in Cyrillic letters). An example of the list is here:

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title></title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>

ua, Корреспондент, http://k.img.com.ua/rss/ua/news.xml
ua, Українська Правда, http://www.pravda.com.ua/rss/

</body>
</html>

The problem appears when I try to apply encode(‘utf-8’) to the Cyrillic letters given in this document. I get an UnicodeDecodeError. Does anybody knows why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:48:11+00:00Added an answer on June 7, 2026 at 5:48 pm

    encode will only give UnicodeDecodeError if you supply it a str object which it then tries to decode to unicode; see http://wiki.python.org/moin/UnicodeDecodeError.

    You need to decode the str object to unicode first:

    name = name.decode('utf-8')
    

    This will take a str in UTF-8 encoding and give you a unicode object.

    It works for the code that you posted because feedparser returns feed data already decoded to unicode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python ndarray temp in some code I'm reading that suffers this:
Say that I have the Python code: someString = file(filename.jpg).read() How can I replicate
I have some python code that I wrote to convert a python list into
I have some python code that currently performs expensive computation by performing the computation
I have a piece of Python code that is supposed to open a new
I have a simple python curses code that creates a subwindow. However, in the
I'm just learning about python. I'm fairly new. I have the following code that
I am reading cpython code for python 3k and I have noticed, that __missing__
I have some code in a python string that contains extraneous empty lines. I
I have a bash code as follows python $TM The problem is that $TM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.