python reptile Learning (Five) Food and Drug Administration licensed the production of cosmetics

And there are a few pit, web url is http://125.35.6.84:81/xk/
only access the home page after the simulation, no data is
then found to be using the ajax, re-find the url
The second pit is the url of data nor is it the final data is a statistic
to get through this next url url id go to the final data access

# -*- coding: utf-8 -*-
import requests
import json
if __name__ == '__main__':
    #批量获取企业id
    url = 'http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsList'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36'
    }
    id_list = []  # 存储企业id
    all_data_list = []  # 存储所有的企业详情数据

    for page in range(1,6):
        page = str(page)
        data={
            'on': 'true',
            'page': page,                #页数
            'pageSize': '15',
            'productName':'',
            'conditionType': '1',
            'applyname':'',
            'applysn':''
        }
        json_ids=requests.post(url=url,headers=headers,data=data).json()
        for dic in json_ids['list']:
           id_list.append( dic['ID'])

    #获取企业详情数据
    post_url = 'http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsById'
    for id in id_list:
        data={
            'id':id
        }
        detail_json=requests.post(url=post_url,headers=headers,data=data).json()
       # print(detail_json,'--------结束')
        all_data_list.append(detail_json)
    #储存到本地
    fp = open('./allData.json','w',encoding='utf-8')
    json.dump(all_data_list,fp=fp,ensure_ascii=False)
    print('结束')
Published 23 original articles · won praise 0 · Views 676

Guess you like

Origin blog.csdn.net/haimian_baba/article/details/103713089