-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
35 lines (31 loc) · 1.14 KB
/
utils.py
File metadata and controls
35 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from bs4 import BeautifulSoup
import logging
import requests
# Get the network names and IDs from MesoWest
#
def get_networks(token):
url = f'https://api.synopticdata.com/v2/networks?&token={token}'
try:
# Send an HTTP GET request to the URL
response = requests.get(url)
# Check if the request was successful (status code 200)
if response.status_code == 200:
# Get the content of the response (the data)
rawStationData = response
return rawStationData.json()
except Exception as e:
logging.warning(e)
# Retrieves all of MesoWest stations information for the United States
#
def get_stations(token):
url=f'https://api.synopticdata.com/v2/stations/metadata?&token={token}&country=us'
try:
# Send an HTTP GET request to the URL
response = requests.get(url)
# Check if the request was successful (status code 200)
if response.status_code == 200:
# Get the content of the response (the data)
rawStationData = response
return rawStationData.json()
except Exception as e:
logging.warning(e)