'''
Copyright (c) 2019.11.23 陈良辉 All rights reserved
本爬虫程序能实现的功能:
1.爬取苹果官网中国店的网页源码,并且解析
2.绘制中国各城市苹果店个数的条形图
3.保存中国所有苹果店的店面图
4.支持城市-具体地址、号码及图片的显示
'''
import requests
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
import os
import matplotlib.image as mpimg
#get_html(url)获取网址源码,并且解析
def get_html(url):
res = requests.get(url)
soup = BeautifulSoup(res.text,"lxml")
return soup
#get_adress(html)将城市为key,地区和网址存为value
def get_adress(html):
adr = {}
for country in html.find('div',id ='cnstores').find_all(attrs={'class':'toggle-section'}):
value = []
for city in country.find('h3'):
key = city
for adress in cou