python统计全国各个地区有多少家乔丹店
#!/usr/bin/env python# coding=utf-8
# Author=stone
import urllib
import re
#定义区域列表
area = ["北京","上海","天津","重庆","河北","山西","辽宁","吉林","黑龙江","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","海南","四川","贵州","云南","陕西","甘肃","青海","台湾","内蒙古","广西","西藏","宁夏","新疆","香港","澳门"]
#获得商店数:
def getShopNumber(getArea):
webCode = urllib.urlopen("http://www.qiaodan.com/shop/shop_search.php?textCode=%s"% getArea)
codeDisplay = webCode.read()
shopNumber = re.findall("contentMaps",codeDisplay)
print getArea,len(shopNumber)
if __name__ == '__main__':
for eachArea in area:
getShopNumber(eachArea)
页:
[1]