Last active
December 11, 2021 10:11
-
-
Save gpirrotta/f32286d65525f7ab535e6083f94fe860 to your computer and use it in GitHub Desktop.
Using Carbon Calculator as python library
This file contains 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
from carbon.calculator import CarbonCalculator | |
from carbon.services import LighthouseService, GreenWebService | |
# If lighthouse tool is installed globally the following row can be omitted | |
lighthouse = LighthouseService(lighthouse = PATH_OF_LIGHTHOUSE_TOOL) | |
# It loads the Green Web Dataset DB (must be a SQL3Lite file) | |
greenweb = GreenWebService(greenweb = PATH_OF_GREEN_DB) | |
# It calculates CO2 emissions | |
carbon = CarbonCalculator(lighthouse=lighthouse, greenweb=greenweb) | |
carbon.footprint("https://www.unime.it") | |
print(carbon.co2_grams) | |
//0.29566587414592505 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment