说明此处仅展示黑龙江省的数据
# ---------------------------------------------------------------------------------------------
#
# 爬取具体数据
# {'哈尔滨盛京白癜风医学研究院': 'https://yyk.99.com.cn/nangang/105610/jianjie.html',
# '黑龙江省青年医学会附属医院': 'https://yyk.99.com.cn/haerbin/98419/jianjie.html',........}
for k, v in info.items():
# # 访问子网,并保存数据
responce = requests.get(url=v, headers={"user-agent": ua.chrome})
if responce.status_code == 200:
responce.encoding = "utf-8"
html = responce.text
with open("first.html", mode="w", encoding="utf-8") as f:
f.write(html)
name = k
link = v
try:
chuang_sum = re.search(r'病床数量</span></td><td><span>(?P<c_n>\d+)</span>', html, re.S | re.M).group(
"c_n") # 病床数量
except:
chuang_sum = 0 # 病床数量
try:
people_yi_h = re.search(
r'<td><span>医护人数</span></td><td><a href="/[a-z]+/\d+/zhuanjia.html">(?D<Pnum>\d+)</a>', html,
re.S | re.M).group("Dnum") # 医护人员数
except:
people_yi_h = 0 # 医护人员数
try:
people_jiuCi = re.search(r'<td><span>年门诊量</span></td><td><span>(?P<Pnum>\d+)</span></td>', html,
re.S | re.M).group("Pnum") # 年就诊人次
except:
people_jiuCi = 0 # 年就诊人次
privice = "黑龙江省"
city_ = city[count].split("(")[0] # 城市
with open("黑龙江省医疗资源统计.csv", mode="a", encoding="utf-8", newline='') as f:
wf = csv.writer(f)
wf.writerow([name, link, chuang_sum, people_yi_h, people_jiuCi, privice, city_])
time.sleep(100) # 每次爬完一个医院数据,休息100秒
else:
name = k
link = v
chuang_sum = 0 # 病床数量
people_yi_h = 0 # 医护人员数
people_jiuCi = 0 # 年就诊人次
privice = "黑龙江省"
city_ = city[count].split("(")[0] # 城市
baocuo_W.append(dict(zip(k, v))) # 报错记录
with open("黑龙江省医疗资源统计.csv", mode="a", encoding="utf-8", newline='') as f:
wf = csv.writer(f)
wf.writerow([name, link, chuang_sum, people_yi_h, people_jiuCi, privice, city_])
time.sleep(random.randint(10, 100)) # 每次爬完一个医院数据,休息一定时间
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Python爬虫及数据可视化—全国医疗资源统计.zip (45个子文件)
Python爬虫及数据可视化—全国医疗资源统计
数据可视化
数据来源.xlsx 2.13MB
China
js
times.js 1KB
online.js 1KB
map.js 2KB
DTU.js 1KB
china.js 59KB
industry.js 22KB
echarts.min.js 700KB
jquery-1.8.0.min.js 90KB
index.js 3KB
PLC.js 1KB
jquery.min.js 84KB
vue.min.js 74KB
China.html 21KB
css
style.css 5KB
images
bg_report.png 8KB
center02.png 9KB
icon06.png 4KB
zuoyi.png 3KB
zuo2.png 7KB
center01.png 17KB
icon03.png 4KB
line.png 3KB
new_list02.png 3KB
bg_data.png 9KB
bg_top.png 81KB
new_list01.png 3KB
bottom_line.png 3KB
hangye.png 9KB
.idea
.name 11B
workspace.xml 13KB
misc.xml 188B
inspectionProfiles
Project_Default.xml 430B
profiles_settings.xml 174B
modules.xml 305B
.gitignore 50B
99医院库.iml 324B
数据采集
first.html 30KB
01爬取黑龙江省医院数据.py 7KB
哈尔滨.csv 2KB
黑龙江省医疗资源统计.csv 246B
具体信息数据代码.txt 3KB
哈尔滨演示案例.html 30KB
02爬取具体数据(哈尔滨演示).py 4KB
医疗源代码_黑龙江.html 198KB
共 45 条
- 1
资源评论
额狮虎
- 粉丝: 15
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功