python抓取省市区的数据并保存到mysql中
代码如下:
# coding: UTF-8
'''
python 抓取网页数据
需要预先安装插件
python -m pip install beautifulsoup4
python -m pip install lxml
'''
import requests
from bs4 import BeautifulSoup
import MySQLdb
import traceback
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
url = 'http://www.360doc.com/content/12/0917/16/1888675_236595612.shtml'
# url = 'http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201703/t20170310_1471429.html'
# hea