Created
February 19, 2014 16:36
-
-
Save brainstorm/9095793 to your computer and use it in GitHub Desktop.
Get amazon remaining grant credits... scraping an AWS site
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
""" | |
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