'What is the best way to scrape NOAA for daily summaries for a specific station for previous weather reports?
This is the code I am using to try to scrape the data from 2001 to 2020, but i keep getting a 'JSONDecodeError: Expecting value: line 1 column 1 (char 0)'
import requests
import pandas as pd
import json
from datetime import datetime
token = 'token'
sta = ['USW00013897', 'USW00013891', 'USW00013893' ]
for year_ in year:
url = 'https://www.ncdc.noaa.gov/cdo-web/api/v2/data?dataset=daily-summaries&dataTypes=PRCP,SNOW,TMAX,TMIN&stations={}&startDate=2001-01-01&endDate=2020-12-31&format=csv'.format(sta)
headers = {"token":token}
r = requests.get(url, "dataset", headers = headers).text
response = json.loads(r)
weather = parsed["dataype"][x]
data.append([x,weather])
print(response)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
