-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# 第1页 | ||
# http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname | ||
#cname: 北京 | ||
# pid: | ||
# pageIndex: 1 | ||
# pageSize: 10 | ||
|
||
# 如何判断是ajax:看核心对象:X-Requested-With:XMLHttpRequest | ||
# 第2页 | ||
# http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname | ||
# post请求 | ||
# cname: 北京 | ||
# pid: | ||
# pageIndex: 2 | ||
# pageSize: 10 | ||
|
||
# 不同的页数其中的pageIndex不同 | ||
|
||
# 通常接口寻找比较麻烦 | ||
|
||
import urllib.request | ||
import urllib.parse | ||
|
||
|
||
def creat_request(page): | ||
base_url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname' | ||
data = { | ||
'cname': '北京', | ||
'pid': '', | ||
'pageIndex': page, | ||
'pageSize': '10', | ||
} | ||
# post请求的参数必须要编码 | ||
data = urllib.parse.urlencode(data).encode('utf-8') | ||
|
||
# 反爬请求头 | ||
headers = { | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36' | ||
} | ||
# 定制 | ||
request = urllib.request.Request(url=base_url, headers=headers, data=data) | ||
return request | ||
|
||
|
||
def get_content(request): | ||
response = urllib.request.urlopen(request) | ||
content = response.read().decode('utf-8') | ||
return content | ||
|
||
|
||
def down_load(page, content): | ||
with open('k'+str(page)+'fc'+'.json', 'w', encoding='utf-8') as fp: | ||
fp.write(content) | ||
|
||
|
||
if __name__ == '__main__': | ||
start_page = int(input('请输入起始页码:')) | ||
end_page = int(input('请输入结束页码:')) | ||
|
||
for page in range(start_page, end_page+1): | ||
# 请求对象的定制 | ||
request = creat_request(page) | ||
# 获取网页源码 | ||
content = get_content(request) | ||
# 下载 | ||
down_load(page, content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":91,"storeName":"广渠路","addressDetail":"广渠路31号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":92,"storeName":"城乡","addressDetail":"复兴路甲23号","pro":"店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":93,"storeName":"机场一号","addressDetail":"首都机场T1航站楼S302","pro":"Wi-Fi,机场店,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":94,"storeName":"通州运河东大街","addressDetail":"运河西大街58号(卜蜂莲花超市西侧)","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":95,"storeName":"广外","addressDetail":"广安门外大街甲180号中国新纪元大厦一层","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":96,"storeName":"机场二号","addressDetail":"首都机场新二号航站楼F1+B1","pro":"Wi-Fi,机场店,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":97,"storeName":"科兴路","addressDetail":"邻枫路1号","pro":"店内参观","provinceName":"北京市","cityName":"北京市"},{"rownum":98,"storeName":"远大路","addressDetail":"海淀区远大路1号中心通道1层北侧","pro":"24小时,Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":99,"storeName":"新一代大厦","addressDetail":"西单北大街堂子胡同9号地下一层","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":100,"storeName":"永定路","addressDetail":"永定路88号长银大厦一层","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":1,"storeName":"前门","addressDetail":"西城区前门西大街正阳市场1号楼中部","pro":"Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":2,"storeName":"京源","addressDetail":"左家庄新源街24号","pro":"Wi-Fi,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":3,"storeName":"东大桥","addressDetail":"朝外大街东大桥路1号楼","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":4,"storeName":"方庄","addressDetail":"蒲芳路26号","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":5,"storeName":"安定门","addressDetail":"安定门外大街西河沿13号楼","pro":"Wi-Fi,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":6,"storeName":"航天桥","addressDetail":"阜成路51-2","pro":"24小时,店内参观","provinceName":"北京市","cityName":"北京市"},{"rownum":7,"storeName":"展览路(德宝)","addressDetail":"西外大街德宝新园14号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":8,"storeName":"劲松","addressDetail":"劲松4区401楼","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":9,"storeName":"西罗园","addressDetail":"西罗园4区南二段","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":10,"storeName":"蓝桥","addressDetail":"蓝桥餐厅工体北路11-1号","pro":"24小时,Wi-Fi,点唱机,礼品卡","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":11,"storeName":"六里桥","addressDetail":"太平桥西里甲1号","pro":"Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":12,"storeName":"万惠","addressDetail":"金台里甲15号","pro":"Wi-Fi,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":13,"storeName":"团结湖","addressDetail":"团结湖路7号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":14,"storeName":"花园路","addressDetail":"花园北路44号贯通大厦一层","pro":"24小时,Wi-Fi,点唱机,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":15,"storeName":"新街口","addressDetail":"新街口北大街50号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":16,"storeName":"酒仙桥","addressDetail":"酒仙桥中路12号乐天玛特一层","pro":"Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":17,"storeName":"华南大厦","addressDetail":"西单北大街178华南大厦B1层","pro":null,"provinceName":"北京市","cityName":"北京市"},{"rownum":18,"storeName":"国展","addressDetail":"静安西街10号国展宾馆一层","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":19,"storeName":"宣武门(四号线G口)","addressDetail":"宣武门东大街24号越秀饭店西配楼一层","pro":"礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":20,"storeName":"建华","addressDetail":"王府井大街192号","pro":"礼品卡","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":21,"storeName":"地安门","addressDetail":"地安门外大街178号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":22,"storeName":"清河","addressDetail":"清河毛纺路南甲36号金五星商业大厦","pro":"店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":23,"storeName":"东单","addressDetail":"东城区东单北大街63号","pro":"Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":24,"storeName":"朝阳门","addressDetail":"朝阳门外大街19号华普大厦(一层东侧)","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":25,"storeName":"通州","addressDetail":"新华东街128号","pro":"Wi-Fi,点唱机,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":26,"storeName":"海淀镇","addressDetail":"海淀街道草场1号","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":27,"storeName":"崇文门","addressDetail":"崇文门外大街3号新世界商场一期北侧一层","pro":"Wi-Fi,点唱机,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":28,"storeName":"苏州桥(紫金大厦一层)","addressDetail":"万泉河路68号紫金大厦一层北侧","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":29,"storeName":"双榆树","addressDetail":"北三环西路48号1#楼FA8商铺","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":30,"storeName":"天坛东路","addressDetail":"天坛东路甲48号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":31,"storeName":"紫竹桥","addressDetail":"海淀区北洼路4号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":32,"storeName":"大兴","addressDetail":"黄村卫星城兴丰街15号,星城商厦一层北侧","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":33,"storeName":"昌平(新世纪商城)","addressDetail":"新世纪商城鼓楼南大街","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":34,"storeName":"和平里","addressDetail":"和平里6区6号楼","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":35,"storeName":"北太平庄","addressDetail":"北三环中路49号","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":36,"storeName":"松榆里","addressDetail":"松榆里28号楼松榆里商场一层北侧","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":37,"storeName":"白石桥","addressDetail":"白石桥路甲54号家乐福超市一层西侧","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":38,"storeName":"右安门","addressDetail":"右安门大街2号迦南公寓C座一层西部","pro":"Wi-Fi,点唱机,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":39,"storeName":"魏公村","addressDetail":"魏公村路5号","pro":"Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":40,"storeName":"阳光广场","addressDetail":"安立路68号阳光广场一层西门北侧","pro":"店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":41,"storeName":"复兴门","addressDetail":"复兴门外大街8号楼裙楼二层","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":42,"storeName":"十里堡","addressDetail":"朝阳路十里堡5号云柏商厦一层西侧","pro":"店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":43,"storeName":"羊坊","addressDetail":"复兴路12号恩菲科技大厦","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":44,"storeName":"延庆","addressDetail":"东外大街4号中踏肯德基","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":45,"storeName":"万商","addressDetail":"石景山路22号万商大厦一层圆弧西侧","pro":"店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":46,"storeName":"房山","addressDetail":"城关南大街2号","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":47,"storeName":"南苑","addressDetail":"南大红门路15号南部现梅源市场1层北侧","pro":"Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":48,"storeName":"洋桥","addressDetail":"大红门西路19号万客隆洋桥店1层西北角","pro":"礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":49,"storeName":"惠新里","addressDetail":"惠新西街23号","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":50,"storeName":"育慧里","addressDetail":"小营东路3号北京凯基伦购物中心一层西侧","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":51,"storeName":"三里河","addressDetail":"月坛南街乙71号","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":52,"storeName":"密云","addressDetail":"鼓楼南大街10号","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":53,"storeName":"苹果园","addressDetail":"苹果园南路126号云柏鞋城","pro":"礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":54,"storeName":"丰台","addressDetail":"西四环南路甲88号","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":55,"storeName":"良乡-69369899","addressDetail":"良乡华冠购物中心一层--楸树街38号(良乡医院对面)","pro":"24小时,Wi-Fi,点唱机,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":56,"storeName":"花园村","addressDetail":"西三环北路70号","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":57,"storeName":"中福百货","addressDetail":"望京南湖东园201楼一层","pro":"24小时,Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":58,"storeName":"上地","addressDetail":"上地东里一区4号楼一层西厅中部","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":59,"storeName":"京通新城","addressDetail":"朝阳路杨闸环岛西北京通苑30号楼一层南侧","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":60,"storeName":"和义","addressDetail":"南苑北里小区二区6号楼一层东南侧","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":61,"storeName":"新兴桥","addressDetail":"复兴路23号二层","pro":"店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":62,"storeName":"旧宫","addressDetail":"旧宫镇旧宫西路3号物美超市一层东南侧","pro":"Wi-Fi,点唱机,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":63,"storeName":"平谷","addressDetail":"平谷区新平北路56-1(世纪广场东侧)","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":64,"storeName":"甘家口","addressDetail":"百万庄大街41号华德商都写字楼北侧一层及二层","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":65,"storeName":"石佛营","addressDetail":"石佛营东里117号楼首层","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":66,"storeName":"门头沟","addressDetail":"门头沟路1号首层","pro":"24小时,Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":67,"storeName":"世都百货","addressDetail":"王府井大街99号世纪大厦首层、地下一层","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":68,"storeName":"云岗","addressDetail":"云岗西路5号首层西侧","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":69,"storeName":"板井路","addressDetail":"远大路远大居住区二期世纪金源大酒店一层东南角","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":70,"storeName":"学院南路","addressDetail":"学院南路50号首层及二层","pro":"店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Table":[{"rowcount":548}],"Table1":[{"rownum":71,"storeName":"珠市口","addressDetail":"东城区珠市口大都市街南八幢一层西侧","pro":"Wi-Fi,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":72,"storeName":"通州新华大街","addressDetail":"新华大街西街56号一层","pro":"24小时,Wi-Fi,点唱机,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":73,"storeName":"五道口","addressDetail":"海淀区成府路35号东源大厦西侧一层","pro":"24小时,Wi-Fi,点唱机,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":74,"storeName":"马莲道","addressDetail":"马莲道路11号","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":75,"storeName":"白广路","addressDetail":"广安门内白广路北口综合服务楼2楼首层(菜百店)","pro":"Wi-Fi,店内参观,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":76,"storeName":"西客站","addressDetail":"莲花池东路31号","pro":"Wi-Fi,礼品卡","provinceName":"北京市","cityName":"北京市"},{"rownum":77,"storeName":"黄寺大街","addressDetail":"黄寺大街15号北京城乡黄寺商厦","pro":"Wi-Fi,点唱机,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":78,"storeName":"光明楼","addressDetail":"光明路13号天玉大厦一、二层","pro":"Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"},{"rownum":79,"storeName":"中关村","addressDetail":"中关村大街18号中关村科技贸易中心一、二层","pro":"店内参观","provinceName":"北京市","cityName":"北京市"},{"rownum":80,"storeName":"白纸坊","addressDetail":"建功南里3号楼首层","pro":"24小时,Wi-Fi,店内参观,礼品卡,生日餐会","provinceName":"北京市","cityName":"北京市"}]} |
Oops, something went wrong.