This commit is contained in:
Yannik Schmidt
2021-05-23 02:29:32 +02:00
parent 52f86a367f
commit 8dfac79e86

View File

@@ -1,5 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys
import os
import requests import requests
import argparse import argparse
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@@ -7,14 +9,18 @@ from bs4 import BeautifulSoup
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('URL', help='URL to query') parser.add_argument('URL', help='URL to query')
parser.add_argument('LOCATION', help='URL to query')
args = parser.parse_args() args = parser.parse_args()
response = requests.get(args.URL) response = requests.get(args.URL)
b = BeautifulSoup(response.content.decode("UTF-8")) b = BeautifulSoup(response.content.decode("UTF-8"), "html.parser")
el = b.find(id="visitorcount-container") el = b.find(id="visitorcount-container")
count = el.get("data-value") count = el.get("data-value")
#os.system("curl http://localhost:8086/write?db=collectd \
# -XPOST --data-binary 'bouldern,ident=zirndorf value={}'".format(count))
postr = requests.post('http://localhost:8086/write?db=collectd', postr = requests.post('http://localhost:8086/write?db=collectd',
data="bouldern,ident=zirndorf {}".format(count)) data="bouldern,ident={} value={}".format(args.LOCATION, count),
print(postr.status) headers={'Content-Type': 'application/octet-stream'})
sys.exit(0) sys.exit(0)