Ошибка Unicode / декодирования с выводом ascii python - PullRequest
0 голосов
/ 14 июля 2020

У меня проблема со следующей ошибкой - думаю, что это текст, содержащий ascii вместо utf-8 или что-то подобное, но я не уверен, как преобразовать его, чтобы перейти к остальная часть кода. Также обратите внимание, что я ограничен python надстройками, которые я могу использовать, поэтому я перечислил импортированные в верхней части кода. Сама ошибка здесь, и мы очень ценим любой совет:

Error Type: <type 'exceptions.UnicodeDecodeError'>
Error Contents: 'ascii' codec can't decode byte 0xc3 in position 986: ordinal not in range(128)
File ".../mainaddon.py", line 56, in get_playable_podcast1
if link.endswith("ttag=season:{}".format(soup1)):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 986: ordinal not in range(128)
-->End of Python script error report<--

Весь код, который я использовал, выглядит следующим образом:

import requests
import re
from bs4 import BeautifulSoup

def get_playable_podcast1(soup1):
    subjects = []
    for content in soup1.find_all('item'):
        try:
            title = content.find('title')
            title = title.get_text()
            link = content.find('enclosure')
            link = link.get('url')
            if link.endswith("ttag=season:{}".format(soup1)):
                urls.append(link) 
        except AttributeError:
            continue
        return subjects
        continue
        item = {
                    'url': link,
                    'title': title,
                    'thumbnail': "..imagehere",
            }
        subjects.append(item)
        return subjects
def compile_playable_podcast1(playable_podcast1):
    items = []
    for podcast in playable_podcast1:
        items.append({
            'label': podcast['title'],
            'thumbnail': podcast['thumbnail'],
            'path': podcast['url'],
            'is_playable': True,
    })
    return items
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...