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='http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do?hKHnQfLv=5XepCUhGtthxergkeXriG5p7YPuhBar58RfhrFFF75IaY37GZXHb6YoqJQa0pxp0o_s7Wr9GBSGKcFO3I5Bv8o6UAS7X9OOVxk44HgD1loGcCulud8GtBG_yc9_RPKq9EjA9KlEu05pSoMe7_kSDCWTGoOfIk65k3H5hhSWZGk0Zec227iUs0pXajBdw1yc0OEwjSgkYhn8yqy9JgSXkCfsIVWc1vK6T22I4P8eFnr.cC9PVZGJBeo_P6orS2v0F1xDpoUSqbZmyAcWpetzER0CHjKPr28V3ZKkeaM.5RsUdUIn8wEQEkzrMgluLrzeY1&8X7Yi61c=4DVTUM2SK89V.PjhQv.kM0BOy5s_y1lFWUwf5.uyN.rVS.zlTHWTH9cWIGCXeghlrfHxcOi02nIUlispMzFcLSE.NfLlo0fb3Fo8rYyoOnFLBLvovmabTfluh7iSwcRsO'    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 = requests.post(url=url,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\models.py", line 910, in json    return complexjson.loads(self.text, **kwargs)  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads    return _default_decoder.decode(s)  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", 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\decoder.py", 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\models.py", 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.
https://en.pythonmana.com/2022/135/202205080409306687.html

Random recommended