[英]Confused by this error tweepy: Failed to send request: Headers indicate a formencoded body but body was not decodable
我有一个带有西班牙语字符的列表(在python中),例如:ó,í,ñ,我正在使用Tweepy库,并想制作一个api.status_update
(列表[element]),但出现此错误...
tweepy.error.TweepError : Failed to send request : \
Indicate Headers formencoded body to body but was not decodable . *
列表元素示例:
u'en esta ocasi \\ xf3n 20口之家拉丁美洲文化中心,80角色su certificaci \\ xf3n
片段代码:
for ultag in sopa.find_all('ul', {'class': 'content'}):
for litag in ultag.find_all('li'):
url = litag.find('a')
textUrl = litag.find('span', {'id': 'noticias_item_extract'})
urlCorta = shortenerUrl(url.get('href'))
i = random.randint(75, 81)
listaCompleta.append(u''.join(textUrl.p.text[:i]+ '...' + ' ' + urlCorta+ ' ' + '#Hash'))
其他摘要:
for i in listaCompleta:
api.update_status(i.encode('utf-8'))
time.sleep(random.randint(30, 45))
简而言之 :您没有正确编码字符。 您需要遵循第二个链接中提供的编码,其中必须为ASCII字符。
可以使用tweepy的init .py中的以下代码片段来跟踪错误代码。
查看第275行,它在内部由tweepy引发,因为:
HTTP请求实体标头包含设置为“ application / x-www-form-urlencoded”的“ Content-Type”标头字段。
您可以通过HTML文档中的“表单”获得有关此信息的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.