4、python爬虫学习——requests肯德基餐厅
2022/7/20 9:19:38
本文主要是介绍4、python爬虫学习——requests肯德基餐厅,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import requests import json header = { 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36' } post_url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword' kw = input('Enter city:') data = { 'cname': '', 'pid': '', 'keyword': kw, 'pageIndex': '1', 'pageSize': '10' } response = requests.post(url=post_url, data=data, headers=header) page_text = response.json() fileName = kw + '.json' fp = open(fileName, 'w', encoding='utf-8') json.dump(page_text, fp=fp, ensure_ascii=False) print('爬取结束!!!')
这篇关于4、python爬虫学习——requests肯德基餐厅的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python