Created
February 23, 2013 04:22
-
-
Save ltiao/5018402 to your computer and use it in GitHub Desktop.
Quick and dirty script to get vividwireless usage data. I'm still figuring out how to get the javascript usage graph
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/python | |
import requests | |
from bs4 import BeautifulSoup | |
EMAIL = '' | |
PASSWORD = '' | |
# Scrape login form and parse into a dict of fields and default vales for form submission | |
payload = {} | |
r = requests.get('https://www.vividwireless.com.au/account/login') | |
soup = BeautifulSoup(r.text) | |
form = soup.find("form", {"id": "vivid-account-login-form"}) | |
for field in form.find_all("input"): | |
if field['type'] in ('text', 'hidden', 'password', 'submit', 'image'): | |
if field.has_key('value'): | |
payload[field['name']] = field['value'] | |
else: | |
payload[field['name']] = '' | |
# Fill in the blanks | |
payload['email'], payload['password'] = EMAIL, PASSWORD | |
# Create a persistent session | |
s = requests.Session() | |
s.post('https://www.vividwireless.com.au/account/login', data=payload) | |
# Use persistent session to get and parse usage page | |
r = s.get('https://www.vividwireless.com.au/account/usage') | |
soup = BeautifulSoup(r.text) | |
print soup.find("div", {"id": "main-column"}).find("div", {"class": "label"}).text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment