37 lines
753 B
Python
37 lines
753 B
Python
#! /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()
|