Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automatically download github bills with CasperJS
login = "<login>"
password = "<password>"
directory = "<directory>"
organization = "<organization>"
casper = require('casper').create
verbose: true
logLevel: "debug"
getLinks = ->
links = document.querySelectorAll ".payment-history tr.succeeded"
Array::map.call links, (e) ->
id: e.querySelector('.id code').textContent.trim()
href: e.querySelector('.receipt a').getAttribute('href')
date: e.querySelector('.date time').getAttribute('title').split(' ').shift()
casper.start "https://github.com/organizations/#{organization}/settings/billing", ->
@fill '[action="/session"]',
login: login
password: password,
true
casper.then ->
@each @evaluate(getLinks), (self, link) ->
# Ex: myfolder/2014-12-01_AAE8EAI.pdf
@download link.href, "#{directory}/#{link.date}_#{link.id}.pdf"
casper.run()
login = "<login>"
password = "<password>"
directory = "<directory>"
casper = require('casper').create
verbose: true
logLevel: "debug"
getLinks = ->
links = document.querySelectorAll "a[href^='/profile/billing/invoices/']"
Array::map.call links, (e) ->
id: e.textContent.trim()
href: e.getAttribute('href')
casper.start "https://scrutinizer-ci.com/profile/billing", ->
@fill '[action="/login_check"]',
"user_login[email]": login
"user_login[password]": password,
true
casper.then ->
@capture "login.png"
@each @evaluate(getLinks), (self, link) ->
# Ex: myfolder/AAE8EAI.pdf
@download link.href, "#{directory}/#{link.id}.pdf"
casper.run()
@charlycoste

This comment has been minimized.

Copy link
Owner Author

@charlycoste charlycoste commented Jan 10, 2015

Launch it with casperjs --ssl-protocol=any download_github_bills.coffee to avoid PhantomJS problem with SSLv3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment