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退出...")
简单的逛了逛饿了么
最新推荐文章于 2021-04-20 10:40:00 发布