[英]Python - Json not decoded
import requests
import json
url = 'http://search.twitter.com/search'
results = requests.get(url)
br = results.json()
出現此錯誤:值錯誤:無法解碼 Json object
請指教...
如果您在瀏覽器中輸入http://search.twitter.com/search
,您會收到一條消息: The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.
The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.
您收到錯誤的原因是在http://search.twitter.com/search
上調用 GET 沒有返回 JSON 字符串。
如果您運行requests.text
,您將看到相同的消息。
如果您收到:值錯誤:否 JSON object 可能是解碼錯誤。
這意味着您的 Python 請求的“結果”無法轉換為 JSON,這意味着您請求的 URL 存在問題。 試試不同的 URL。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.