Skip to content

Instantly share code, notes, and snippets.

@brainstorm
Created February 19, 2014 16:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainstorm/9095793 to your computer and use it in GitHub Desktop.
Save brainstorm/9095793 to your computer and use it in GitHub Desktop.
Get amazon remaining grant credits... scraping an AWS site
"""
Fetches the remaining EDU grant credits in an Amazon account using scraping
with Python's RoboBrowser (perl's WWW::Mechanize look-alike)
"""
from robobrowser import RoboBrowser
credits_url = 'https://portal.aws.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=credits'
browser = RoboBrowser(history=True)
browser.open(credits_url)
form = browser.get_form()
# Sorry, no proper credentials security until Amazon exposes this attribute
# as a proper API call (perhaps via CloudWatch Billing?)
form['email'].value = '<AWS_USERNAME>'
form['password'].value = '<AWS_PASSWORD>'
browser.submit_form(form)
for field in browser.response.text.split('\n'):
if 'Credits Balance' in field:
print field.split('$')[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment