current position:Home>About Python Crawlers

About Python Crawlers

2022-05-15 04:39:01CSDN Q & A

Practice in one course But it didn't work
The code is as follows :

import requestsimport jsonif __name__=="__main__":    url=''    data={ 
            "on": "true",        "page": "1",        "pageSize": "15",        "productName":"",        "conditionType": "1",        "applyname":"",        "applysn":"",    }    headers = { 
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36'}    id_list = []# Storage enterprise id    response =,headers=headers,data=data)    json_ids = response.json()    for dic in json_ids["list"]:     # dic  Dictionaries         id_list.append(dic["ID"])    print(id_list) An error is as follows :```pythonTraceback (most recent call last):  File "C:\Users\Administrator\PycharmProjects\pythonProject\venv\lib\site-packages\requests\", line 910, in json    return complexjson.loads(self.text, **kwargs)  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\", line 346, in loads    return _default_decoder.decode(s)  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\", line 337, in decode    obj, end = self.raw_decode(s, idx=_w(s, 0).end())  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\", line 355, in raw_decode    raise JSONDecodeError("Expecting value", s, err.value) from Nonejson.decoder.JSONDecodeError: Expecting value: line 4 column 1 (char 6)During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "C:\Users\Administrator\PycharmProjects\pythonProject\ Food and Drug Administration .py", line 24, in <module>    json_ids = response.json()  File "C:\Users\Administrator\PycharmProjects\pythonProject\venv\lib\site-packages\requests\", line 917, in json    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)requests.exceptions.JSONDecodeError: [Errno Expecting value] : 6Process finished with exit code 1


Take the answer :

headers completion

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended