Bootstrap

网络爬虫——药品总局相关数据获取(requests)

import requests
import json
if __name__ == '__main__':
    url = 'http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do?method=getXkzsList'
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
    }
    id_list = []
    all_id_list = []
    for page in range(1,5):
        page=str(page)        #注意这里要转化为字符串形式
        data = {
            'on': 'true',
            'page': page,
            'pageSize': '15',
            'productName':'',
            'conditionType': '1',
            'applyname':'',
            'applysn':'',
        }

        response = requests.post(url=url,data=data,headers=headers)
        dic_data = response.json()
        for dic in dic_data[
;