First version, get current price with CLI
This commit is contained in:
36
fioul.py
Normal file
36
fioul.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
# from bottle import hook, request, route, run, static_file, view
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
query = """query {
|
||||||
|
getProductGroups(category: 1, zipcode: 1184) {
|
||||||
|
name
|
||||||
|
default_price_tax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def get_price():
|
||||||
|
response = requests.post(
|
||||||
|
url="https://www.bretagne-multi-energies.fr/graphql",
|
||||||
|
json={"query": query},
|
||||||
|
headers={"content-type": "application/json"},
|
||||||
|
)
|
||||||
|
json_data = json.loads(response.text)
|
||||||
|
products = json_data["data"]["getProductGroups"]
|
||||||
|
product = next(
|
||||||
|
filter(lambda x: x["name"] == "Fioul Domestique Standard", products), None
|
||||||
|
)
|
||||||
|
return product["default_price_tax"]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print(get_price())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user