Created
March 27, 2018 23:54
-
-
Save Jun-Dai/d02f6c0ccdee1c5b07bb88cde31c4415 to your computer and use it in GitHub Desktop.
Fetching transactions off of CrowdCube and Seedrs
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
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