[英]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.