Created
August 30, 2016 18:53
-
-
Save mralext20/05db563408ea7400353bf37e1ae1cd53 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
from lxml import html | |
import requests | |
import re | |
from datetime import date | |
from calendar import monthrange | |
date = date.today() | |
year = date.year | |
month= date.month | |
numberOfDays = monthrange(year,month) | |
numberOfDays = numberOfDays[1] | |
page = requests.get('https://apps.gci.com/cp/warning/rethink/90?SN=083E0CFA30E9&IP=REDACTEDIPADDRESS&TH=80&W=CMRR300GB&TS=1472174664&um=') | |
tree = html.fromstring(page.content) | |
target = tree.xpath('//*[@id="warning_message"]/p[2]/b[3]/text()') | |
remainingDays = tree.xpath('//*[@id="warning_message"]/p[2]/b[1]/text()') | |
totalUsage = tree.xpath('//*[@id="warning_message"]/p[2]/b[4]/text()') | |
target = float(target[0]) | |
remainingDays = float(remainingDays[0]) | |
totalUsage = float(re.findall('\d+', totalUsage[0])[0]) | |
print('used so far this month:', target,'GB') | |
#math | |
print('remaining: ', format(300-target, '.2f'),'GB') | |
print(' ') | |
print(format(target/totalUsage*100,'.2f'),'% used so far') | |
print(' ') | |
optimalUsagePerDay = totalUsage/numberOfDays | |
averageUsagePerDay = (target/(numberOfDays-remainingDays)) | |
print("optimal usage per day this month: ", format(optimalUsagePerDay,'.2f'),"GB per day") | |
print("average usage per day this month: ", format(averageUsagePerDay,'.2f'),"GB per day so far") | |
if optimalUsagePerDay > averageUsagePerDay: | |
print('you are underusing data! GOOD!') | |
else: | |
print('you are OVER USING DATA! THIS IS BAD! SLOW DOWN') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment