feat:重构request请求模块
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import requests
|
||||
from datetime import datetime
|
||||
|
||||
from message.request_message import send_request
|
||||
|
||||
weather_url = 'https://p478kygkjw.re.qweatherapi.com'
|
||||
weather_api_key = '4aa47f183c694aaa812ff018be8270e4'
|
||||
nanjing_location = '101190101'
|
||||
@@ -8,19 +9,21 @@ nanjing_location = '101190101'
|
||||
|
||||
def get_today_weather(city_location=nanjing_location):
|
||||
url = f'{weather_url}/v7/weather/3d'
|
||||
response = requests.get(
|
||||
|
||||
response = send_request(
|
||||
url=url,
|
||||
method="GET",
|
||||
headers={'X-QW-Api-Key': f'{weather_api_key}'},
|
||||
params={'location': city_location}
|
||||
)
|
||||
params={'location': city_location})
|
||||
|
||||
return response.json()
|
||||
|
||||
|
||||
def get_today_indices(city_location=nanjing_location):
|
||||
url = f'{weather_url}/v7/indices/1d'
|
||||
response = requests.get(
|
||||
response = send_request(
|
||||
url=url,
|
||||
method="GET",
|
||||
headers={'X-QW-Api-Key': f'{weather_api_key}'},
|
||||
params={'location': city_location, 'type': '0'}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user