Giter VIP home page Giter VIP logo

carchargewithhourcurrentrates's People

Contributors

smokkelaar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

carchargewithhourcurrentrates's Issues

Prijsentsoe cannot resolve

By the looks of the website it seems they changed a bit of stuff. Probably filling datafields from another source than before which can't be handled by requests. Found out that selenum can do this.

I would like to put in a pull request but im not sure how things get handled when summer and wintertime changes. Please let me know what you think!


import datetime as dt
from selenium import webdriver
from bs4 import BeautifulSoup



#######################################################
###Input: none
###Function: Get the day ahead prices form entsoe, and transform them to price per kWh including taxation. (*0.00121)
###Output: List of upcoming prices so far as possible. in the format: list[time, price buy, price sell]
#######################################################

def Ophalen():
    nu = dt.datetime.now(dt.timezone.utc)
    morgen = nu + dt.timedelta(days=1)
    urlvandaag = "https://transparency.entsoe.eu/transmission-domain/r2/dayAheadPrices/show?name=&defaultValue=false&viewType=TABLE&areaType=BZN&atch=false&dateTime.dateTime="+"{:02d}".format(nu.day)+"."+"{:02d}".format(nu.month)+"."+str(nu.year)+"+00:00|CET|DAY&biddingZone.values=CTY|10YNL----------L!BZN|10YNL----------L&resolution.values=PT60M&dateTime.timezone=CET_CEST&dateTime.timezone_input=CET+(UTC+1)+/+CEST+(UTC+2)"
    urlmorgen = "https://transparency.entsoe.eu/transmission-domain/r2/dayAheadPrices/show?name=&defaultValue=false&viewType=TABLE&areaType=BZN&atch=false&dateTime.dateTime="+"{:02d}".format(morgen.day)+"."+"{:02d}".format(morgen.month)+"."+str(morgen.year)+"+00:00|CET|DAY&biddingZone.values=CTY|10YNL----------L!BZN|10YNL----------L&resolution.values=PT15M&resolution.values=PT30M&resolution.values=PT60M&dateTime.timezone=CET_CEST&dateTime.timezone_input=CET+(UTC+1)+/+CEST+(UTC+2)"

    #print(urlvandaag)
    #print (urlmorgen)

    pagevandaag = webdriver.Chrome()
    pagemorgen = webdriver.Chrome()
    pagevandaag.get(urlvandaag)
    pagemorgen.get(urlmorgen)   
    
    soupv = BeautifulSoup(pagevandaag.page_source, 'html.parser')
    soupm = BeautifulSoup(pagemorgen.page_source, 'html.parser')

    pagevandaag.quit()
    pagemorgen.quit()

    price_hidev = soupv.find_all(class_='dv-value-cell')
    price_hidem = soupm.find_all(class_='dv-value-cell')
    returnvalues = []
    for price in price_hidev:
        try:
            #print(price)
            noISOdatum = str(price).split("\', \'")[2]
            
            datum = dt.datetime.fromisoformat(noISOdatum[:-1]) + dt.timedelta(hours=3)

            if ((datum.timestamp() - nu.timestamp()) >= 0):
                #print(datum + dt.timedelta(hours=-1))
                #print(price.text)
                returnvalues.append([datum, str(round(float(price.text)*0.00121, 7)), str(round(float(price.text)*0.00121, 7))])
        except:
            pass
    try:
        for price in price_hidem:
            try:
                #print(price)
                noISOdatum = str(price).split("\', \'")[2]
                datum = dt.datetime.fromisoformat(noISOdatum[:-1]) + dt.timedelta(hours=3)

                if ((datum.timestamp() - nu.timestamp()) >= 0):
                    #print(datum + dt.timedelta(hours=-1))
                    #print(price.text)
                    returnvalues.append([datum, str(round(float(price.text)*0.00121, 7)), str(round(float(price.text)*0.00121, 7))])
            except:
                pass
    except:
        pass
    return returnvalues

Entsoe Time differiation depending on system that runs the code

Depending on the system where it runs you get a different current time.

my own system:
huidige prijs op dit moment: 0.2226153
Minimaleprijs de komende uren: 0.2009926
Maximaleprijs de komende uren: 0.2304198
23.86924342105268

Pythonanywhere:
aantal gegevens easy 34
aantal gegevens entsoe 35
prijs dit uur easy 0.0628353
prijs dit uur entsoe 0.0616495
huidige prijs op dit moment: 0.2214295
Minimaleprijs de komende uren: 0.2009926
Maximaleprijs de komende uren: 0.2304198
27.495888157894743

So something is going on with terminating the current timezome.
manual work arround is, change the time in entsoe to -3600 instead of -7200.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.