Python Reptile real small projects

Crawling State Administration Drug Administration based on data related to license production of cosmetics People's Republic of China

import requests
from fake_useragent import UserAgent
ua = UserAgent(use_cache_server=False,verify_ssl=False).random
headers = {
    'User-Agent':ua
}
url = 'http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsList'
pageNum = 3
for page in range(3,5):
    data = {
        'on': 'true',
        'page': str(page),
        'pageSize': '15',
        'productName':'',
        'conditionType': '1',
        'applyname':'',
        'applysn':''
    }
    json_text = requests.post(url=url,data=data,headers=headers).JSON () 
        ID = dict [ 'ID'] # for two page data acquisition
    all_id_list = []
    for dict in json_text['list']:
        # The following information can be obtained before the two pages 
        # name = dict [ 'EPS_NAME'] 
        # Product dict = [ 'PRODUCT_SN'] 
        # = man_name dict [ 'QF_MANAGER_NAME'] 
        # D1 = dict [ 'XC_DATE'] 
        # = D2 dict [ 'XK_DATE'] 
        all_id_list.append (ID) 
    # is the url of a post request ajax 
    POST_URL = 'http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsById' 
    for ID in all_id_list : 
        post_data = { 
            'ID': ID 
        } 
        Response = requests.post (= POST_URL URL, Data = post_data, headers = headers)  
        IF Response.Headers [' Content-Type '] ==' application / json;charset=UTF-8':
            #Print (response.json ()) 
            # json be resolved 
            json_text = response.json ()
            print(json_text['businessPerson'])

  

Guess you like

Origin www.cnblogs.com/xuange1/p/12045582.html