Привет, я сделал HTTP GET-запрос, используя запросы lib в python3. когда я пытался просмотреть ответ как JSON, я получил эту ошибку:
import requests
URL = 'http://10.10.10.28/cdn-cgi/login/admin.php'
PARAMS = {'content':'accounts', 'id':'1'}
COOKIES = {'role':'admin', 'user':'34322'}
r = requests.get(url= URL, params= PARAMS, cookies= COOKIES)
r.json()
Получил
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Это r:
>>> r
<Response [200]>
И это r.content:
>>> r.content
b'<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="UTF-8">\n<title>Admin Panel</title>\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<link rel=\'stylesheet\' href=\'/css/bootstrap.min.css\'>\n<link rel=\'stylesheet\' href=\'/css/ionicons.min.css\'>\n<style>\n.container {\n max-width: 960px;\n}\n.navbar-survival101 {\n background-color:#2B6DAD;\n}\n/* .navbar-survival101 .navbar-brand {\n margin-right: 2.15rem;\n padding: 3px 0 0 0;\n line-height: 36px;\n} */\n\n.navbar-survival101 .navbar-brand img {\n vertical-align: baseline;\n}\n\n.navbar-expand-lg .navbar-nav .nav-link {\n color: #fff;\n}\n\n.search-box {\n position: relative;\n height: 34px;\n}\n.search-box input {\n border: 0;\n border-radius: 3px !important;\n padding-right: 28px;\n font-size: 15px;\n}\n\n.search-box .input-group-btn {\n position: absolute;\n right: 0;\n top: 0;\n z-index: 999;\n}\n\n.search-box .input-group-btn button {\n background-color: transparent;\n border: 0;\n padding: 4px 8px;\n color: rgba(0,0,0,.4);\n font-size: 20px;\n}\n\n.search-box .input-group-btn button:hover,\n.search-box .input-group-btn button:active,\n.search-box .input-group-btn button:focus {\n color: rgba(0,0,0,.4);\n}\n\n@media (min-width: 992px) {\n .navbar-expand-lg .navbar-nav .nav-link {\n padding-right: .7rem;\n padding-left: .7rem;\n }\n\n.new {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width:30%;\n}\n\ntable {\n font-family: arial, sans-serif;\n border-collapse: collapse;\n width: 60%;\n}\n\ntd, th {\n border: 1px solid #dddddd;\n text-align: center;\n padding: 8px;\n}\n\ntr:nth-child(even) {\n background-color: #dddddd;\n} \n .search-box {\n width: 300px !important;\n }\n}\n\n.caroulsel {\n width: 100%;\n overflow: hidden;\n padding: 5px 0 5px 5px;\n}\n\n.caroulsel-wrap {\n white-space: nowrap;\n font-size: 0;\n}\n\n.caroulsel-wrap a {\n display: inline-block;\n width: 134px;\n height: 92px;\n background-color: silver;\n border: #ccc 1px solid;\n margin-right: 5px;\n}\n</style>\n<script>\n window.console = window.console || function(t) {};\n</script>\n<script>\n if (document.location.search.match(/type=embed/gi)) {\n window.parent.postMessage("resize", "*");\n }\n</script>\n</head>\n<body translate="no">\n<nav class="navbar navbar-expand-lg navbar-dark navbar-survival101">\n<div class="container">\n<a class="navbar-brand" href="#">\nMegaCorp Automotive\n</a>\n<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">\n<span class="navbar-toggler-icon"></span>\n</button>\n<div class="collapse navbar-collapse" id="navbarColor02">\n<ul class="navbar-nav mr-auto">\n<li class="nav-item active">\n<a class="nav-link" href="/cdn-cgi/login/admin.php?content=accounts&id=1">Account<span class="sr-only">(current)</span></a>\n</li>\n<li class="nav-item">\n<a class="nav-link" href="/cdn-cgi/login/admin.php?content=branding&brandId=10">Branding</a>\n</li>\n<li class="nav-item">\n<a class="nav-link" href="/cdn-cgi/login/admin.php?content=clients&orgId=1">Clients</a>\n</li>\n<li class="nav-item">\n<a class="nav-link" href="/cdn-cgi/login/admin.php?content=uploads">Uploads</a></li>\n<li class="nav-item">\n<a class="nav-link" href="#">Logged in as Admin</a>\n</li>\n</ul>\n<form class="form-inline">\n</span>\n</div>\n</form>\n</div>\n</div>\n</nav>\n<br /><br /><center><h1>Repair Management System</h1><br /><br />\n<table><tr><th>Access ID</th><th>Name</th><th>Email</th></tr><tr><td>34322</td><td>admin</td><td>admin@megacorp.com</td></tr></table<script src=\'/js/jquery.min.js\'></script>\n<script src=\'/js/bootstrap.min.js\'></script>\n</body>\n</html>\n'
Спасибо.