简单的逛了逛饿了么

import requests
import re

def get_one_html(url):
	header={"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101  Firefox/28.0"}
	try:
		response = requests.get(url, headers=header)
		response.raise_for_status()

	except Exception :
		pass
	else:
		return response.json()


def handle_json(json):
	for i in json:
		print("---------------------------------")
		print("Store name: " + i.get("name", ""))

		print("flavors: ", end='')
		for item in i.get("flavors"):
			print(item.get("name"),end="  ")
		print("")

		print("rating: " + str(i.get("rating")))
		print("Store-Link: https://www.ele.me/shop/" + i.get("id"))
		print("recommend_reasons: ",end="")
		for item in i.get("recommend_reasons"):
			print(item.get("name"),end='  ')
		print("")
		print("opening_hours: ", i.get("opening_hours")[0])
		print("")

if __name__ == '__main__':
	url = "https://www.ele.me/restapi/shopping/restaurants?extras%5B%5D=activities&latitude={维度替换}&limit=24&longitude={经度替换}&offset={}"
	# 当然可以直接到网站登录找到相关的经纬度带入,或者直接替换链接
	
	for i in range(0, 5):
		json = get_one_html(url.format(24*i))
		print(i)
		handle_json(json)
		print("--"*20)
	input("按Enter退出...")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值