-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (24 loc) · 738 Bytes
/
app.py
File metadata and controls
29 lines (24 loc) · 738 Bytes
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
import urllib3
import json
from datetime import datetime, timezone
from bs4 import BeautifulSoup
HTTP = urllib3.PoolManager()
URL = 'http://dk0wcy.de/magnetogram/'
RESPONSE = HTTP.request('GET', URL)
SOUP = BeautifulSoup(RESPONSE.data, features="html.parser")
TAG = SOUP.find_all("b")
exitformat = {
'timestamp':
datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SUTC"),
'dx-data': {
'sfi': TAG[8].text.strip(),
'ssn': TAG[6].text.strip(),
'aurora': TAG[7].text.strip(),
'a-index': TAG[3].text.strip(),
'k-index': TAG[4].text.strip(),
'solar_activity': TAG[2].text.strip(),
'magnetic_field': TAG[5].text.strip()
}
}
print()
print(json.dumps(exitformat))