Created
April 2, 2019 16:57
-
-
Save techsin/c675cc70800507ce5753cb0f4f12c352 to your computer and use it in GitHub Desktop.
Scraping Angellist to csv
This file contains hidden or 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
class Company { | |
name; | |
desc; | |
joined; | |
location; | |
market; | |
website; | |
employees; | |
stage; | |
constructor(...rest) { | |
[this.name, this.desc, this.joined, this.location, this.market, this.website, this.employees, this.stage] = rest; | |
} | |
} | |
function getText(css, ele) { | |
return ele.querySelector(css).innerText; | |
} | |
let data = companies.map( (ele)=> { | |
let name = getText('.company.column .text .name', ele), | |
desc = getText('.company.column .text .pitch', ele), | |
joined = getText('.joined.column .value', ele), | |
location = getText('.location.column .value', ele), | |
market = getText('.market.column .value', ele), | |
website = getText('.website.column .website', ele), | |
employees = getText('.company_size.column .value', ele), | |
stage = getText('.stage.column .value', ele); | |
return new Company(name, desc, joined, location, market, website, employees, stage); | |
}); | |
function convertToCSV(arr) { | |
return arr.map(function(obj){ | |
let str = ""; | |
for (let key in obj) { | |
str += `"${obj[key]}"`; | |
str += ','; | |
} | |
str = str.slice(0,-1); | |
return str; | |
}).join('\n'); | |
} | |
copy(convertToCSV(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment