Last active
May 22, 2023 19:31
-
-
Save Veticus/b111b4ffdeb0d02ec6b124241db68644 to your computer and use it in GitHub Desktop.
Bad attempt at getting the european power grid supply frequency from swissgrid.ch. By the time someone reads this, the URL probably doesn't do the trick anymore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import urllib.parse | |
import ast | |
import codecs | |
url = "http://www.swissgrid.ch/mvc.do/applicationFrequencyTimeAjax?tooltipText=+Live+data+(updated+every+30+seconds%2c+capacity+data+delayed+by+20+minutes)&deviationText=Current+grid+time+deviation&frequencyText=Current+frequency&_charset_=UTF-8" | |
enc = codecs.encode(str.encode(url), "hex") | |
print(enc) | |
dec = str(codecs.decode(enc, "hex"))[2:-1] | |
url2 = '"' + dec + '"' | |
print(url2) | |
f = urllib.request.urlopen(url2) | |
gotten = f.read().decode('utf-8') | |
topcut = gotten.split("\n")[24] | |
freq = ast.literal_eval(topcut[36:-10]) | |
print(freq) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment