爬虫s3(简单的信息爬取)

import requests
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'

}
url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
for page in range(1,9):
    data = {
        'cname':'',
        'pid':'',
        'keyword': '北京',
        'pageIndex': str(page),
        'pageSize': '10',
    }
#data参数是post方法中处理参数动态化的参数
response     =  requests.post(url=url,data=data,headers=headers)
page_text = response.json()
for dic in page_text['Table1']:
    title = dic['storeName']
    addr = dic['addressDetail']
    print(title,addr)
上一篇:模拟抢票系统


下一篇:python37实现1-统计文本中出现次数最多的单词