How can I retrieve this data in the graph from this site and then save it in a DataFrame using python?
https://umm.gassco.no/reductionFields
I have tried to retrieve the data with this code but do not know how to proceed
import requests
s=requests.session() s1=s.get("https://umm.gassco.no/reductionFields") s2=s.get("https://umm.gassco.no/disclaimer/acceptDisclaimer?")
To get the data from graph as Pandas DataFrame you can use next example:
import re
import requests
import pandas as pd
url = "https://umm.gassco.no/reductionFields"
redir_url = "https://umm.gassco.no/disclaimer/acceptDisclaimer?"
with requests.session() as s:
s.get(url)
html_doc = s.get(redir_url).text
df = pd.DataFrame(
{"Time": a, "Value": b}
for a, b in re.findall(r"d3\.push\(\[(.*?), (.*?)\]\)", html_doc)
)
df['Time'] = pd.to_datetime(df['Time'], unit='ms')
print(df.head())
Prints:
Time Value
0 2023-04-18 10:00:00 -50.93000000000001
1 2023-04-19 10:00:00 -40.93
2 2023-04-20 10:00:00 -60.92999999999999
3 2023-04-21 10:00:00 -60.92999999999999
4 2023-04-22 10:00:00 -60.92999999999999
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With