Skip to content

Commit

Permalink
stations fix
Browse files Browse the repository at this point in the history
  • Loading branch information
solomon-negusse committed Mar 23, 2019
1 parent 4589a1a commit a74ecae
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ulmo/usace/swtwc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ def get_stations():
a python dict with station codes mapped to station information
"""
stations_url = 'http://www.swt-wc.usace.army.mil/shefids.htm'
path = os.path.join(USACE_SWTWC_DIR, 'shefids.htm')

with util.open_file_for_url(stations_url, path) as f:
soup = BeautifulSoup(f)
pre = soup.find('pre')
links = pre.find_all('a')
stations = [
_parse_station_link(link) for link in links
]

headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36'
}
resp = requests.get(stations_url, headers=headers)
soup = BeautifulSoup(resp.content)
pre = soup.find('pre')
links = pre.find_all('a')
stations = [
_parse_station_link(link) for link in links
]

return dict([
(station['code'], station)
Expand Down

0 comments on commit a74ecae

Please sign in to comment.