1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
import requests import json
if __name__ == "__main__": id_list = [] all_data_list = [] headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.44' }
url = 'http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do?method=getXkzsList' for page in range(1, 10): page = str(page) data = { 'on': 'true', 'page': page, 'pageSize': '15', 'productName': '', 'conditionType': '1', 'applyname': '', 'applysn': '' } response = requests.post(url=url, headers=headers, data=data) page_json = response.json() for dic in page_json['list']: id_list.append(dic['ID']) allUrl = 'http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do?method=getXkzsById' for allId in id_list: idData = { 'id': allId } allResponse = requests.post(url=allUrl, headers=headers, data=idData) page_allJson = allResponse.json() all_data_list.append(page_allJson) fp = open('./allData.json', 'w', encoding='utf-8') json.dump(all_data_list, fp=fp, ensure_ascii=False) print('列表枚举成功!!!')
|