python - JSONDecodeError:期望值:第 7 行第 1 列(字符 6)
问题描述
我想生成一个http请求响应,我还需要响应代码和数据,即我想获取与我的查询相关的所有条目。我的代码如下,每当我尝试以json格式提取它时都会出错。我想获取与 http 协议相关的所有数据。请告诉我我的代码有什么问题。
import censys
import requests
import json
URL ="https://censys.io/ipv4"
UID =""
SECRET = ""
location = "https"
PARAMS = {'address':location}
r = requests.get(url = URL,auth=(UID, SECRET),params = PARAMS)
print(r)
# extracting data in json format
data=r.json()
输出
<Response [200]>
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-23-d8dbe8fb36c9> in <module>()
17 print(r)
18 # extracting data in json format
---> 19 data=r.json()
/usr/local/lib/python3.6/dist-packages/requests/models.py in json(self, **kwargs)
890 # used.
891 pass
--> 892 return complexjson.loads(self.text, **kwargs)
893
894 @property
/usr/lib/python3.6/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
352 parse_int is None and parse_float is None and
353 parse_constant is None and object_pairs_hook is None and not kw):
--> 354 return _default_decoder.decode(s)
355 if cls is None:
356 cls = JSONDecoder
/usr/lib/python3.6/json/decoder.py in decode(self, s, _w)
337
338 """
--> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()
341 if end != len(s):
/usr/lib/python3.6/json/decoder.py in raw_decode(self, s, idx)
355 obj, end = self.scan_once(s, idx)
356 except StopIteration as err:
--> 357 raise JSONDecodeError("Expecting value", s, err.value) from None
358 return obj, end
JSONDecodeError: Expecting value: line 7 column 1 (char 6)
解决方案
推荐阅读
- node.js - 如何在 React 应用程序中禁用文件监视
- arrays - BigIntegers 如何在基础层面详细工作?
- javascript - TypeError:在 React Enzyme 中加载脚本时无法读取未定义的属性“src”
- c# - 如何在 wpf 材料设计中更新 dialoghost 的内容?
- javascript - 使用 document.getElementById('').innerHTML 打印出一个数组会忽略 HTML 和 CSS
- javascript - javascript 在具有 2 个标题的表中插入新行
- 3d - matlab或python中的聚类分析 - 三维数据上的k-means聚类
- c++ - 使用 G++ 编译时出现“未定义的对 Foo 的引用”
- flutter - 颤动的firebase错误“失败:构建失败并出现异常”
- c++ - unordered_set 范围插入 VS 迭代器