爬虫:requset药监局数据

爬虫:requset药监局数据,第1张

import json

import requests

url = 'http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do'
page = input('请输入查看药监局第几页的企业:')
data = {
    'method': 'getXkzsList',
    'on': 'true',
    'page': page,
    'pageSize': '15',
    'productName': '',
    'conditionType': '1',
    'applyname': '',
    'applysn': ''
}
header={
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}

respone = requests.post(url=url, data=data, headers=header)
dic = respone.json()

fp = open('./yaojianju.json', 'w', encoding='utf-8')

json.dump(dic, fp=fp, ensure_ascii=False)


number = int(input('请输入查看药监局第几家的企业:'))-1
id = dic['list'][number]['ID']
print(dic['list'][number]['ID'])

url = 'http://scxk.nmpa.gov.cn:81/xk/itownet/portalAction.do'
data = {
    'method': 'getXkzsById',
    'id': id
}
header={
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}

respone = requests.post(url=url, data=data, headers=header)
dic = respone.json()
businessPerson = dic['businessPerson']
print(businessPerson)
filename = businessPerson + '.json'
fp = open(filename, 'w', encoding='utf-8')

json.dump(dic, fp=fp, ensure_ascii=False)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/724975.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-26
下一篇 2022-04-26

发表评论

登录后才能评论

评论列表(0条)

保存