Skip to content

Instantly share code, notes, and snippets.

@Jun-Dai
Created March 27, 2018 23:54
Show Gist options
  • Save Jun-Dai/d02f6c0ccdee1c5b07bb88cde31c4415 to your computer and use it in GitHub Desktop.
Save Jun-Dai/d02f6c0ccdee1c5b07bb88cde31c4415 to your computer and use it in GitHub Desktop.
Fetching transactions off of CrowdCube and Seedrs
txns = $('<div id="transactions">')
var counter = 0
var output = ""
var asdf = copy
var parse = () => {
txns.find(".cc-table__row").each((i, elem) => {
var investment = $(elem).data("amount-formatted")
var name = $(elem).data("company")
var date
var status
$(elem).find(".cc-table__cell").each((j, cell) => {
if(j == 0) {
date = $.trim($(cell).text())
} else if (j == 2) {
status = $.trim($(cell).text())
}
})
output += `${date}\t${name}\t${investment}\t${status}\n`
})
asdf(output)
console.log(`Copied ${output.split("\n").length} lines to clipboard`)
}
var fetch = (cursor) => {
var qstring = cursor ? `?cursor=${cursor}` : ""
var url = `https://www.crowdcube.com/account/transactions${qstring}`
console.log(`fetching: ${url}`)
$.ajax(url).done((response) => {
counter += response.cursor.count
txns.append(response.content)
if (response.cursor.next) {
fetch(response.cursor.next)
} else {
console.log(counter)
console.log(response.cursor)
parse()
}
})
}
fetch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment