Created
February 25, 2018 21:07
-
-
Save boxmein/fd2dfa99f4291aedc61c4957cad729d9 to your computer and use it in GitHub Desktop.
Script to parse Startup Estonia data and output a HTML file.
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
</body> | |
</html> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width"> | |
<title>Startup Estonia andmed</title> | |
<style> | |
body { | |
max-width: 600px; | |
margin: 0 auto; | |
font-size: 16px; | |
font-family: Lato, Ubuntu, Arial, sans-serif; | |
color: #303030; | |
line-height: 1.5; | |
white-space: pre-line; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Startup Estonia andmetel on:</h1> |
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
#!/bin/bash | |
# Programm, mis väljastab idufirmade (startupide) nimistu Startup Estonia andmetel. | |
# Kasutab JSON formaadis andmete lugemiseks käsureaprogrammi nimega 'jq', mille | |
# saab alla laadida Ubuntus: | |
# $ sudo apt install jq | |
# https://stedolan.github.io/jq/ | |
# Loe startup estonia lehelt maha Javascript-fail andmetega Funderbeami startupide | |
# nimistust, filtreerides välja ainult JSON koostamiseks vajalikud objektid ja | |
# koostades JSON listi. Salvesta see list startups.json faili | |
( | |
echo "["; | |
wget -qO- http://www.startupestonia.ee/javascripts/funderbeamData.js | grep '{"name"'; | |
echo "]" | |
) > startups.json | |
# Alusta uue failiga "uus.html", kasutades ära faili "tyhi" sisu. | |
cp tyhi.html uus.html | |
# Iga kirje korral startups.json'is, filtreerides välja kirjed millel rahastust | |
# puudub, väljasta tekst (koos HTML tag'iga <br>) | |
# "(nimi) has received (rahastus)$ in funding <br>" | |
cat startups.json | jq -r '.[] | select(.funding != null) | .name + " has received " + (.funding | tostring) + "$ in funding"' >> uus.html | |
# Iga kirje korral startups.json'is, filtreerides välja kirjed, millel ei ole investoreid, | |
# väljasta iga investori kohta tekst: | |
# "(nimi) has investor: (investori nimi)" | |
cat startups.json | jq -r '.[] | select(.investors != []) | .name + " has investor: " + (.investors[].name)' >> uus.html | |
# Lõpeta HTML leht | |
cat lopp.html >> uus.html | |
# Koristustöö - eemalda ajutised failid | |
rm startups.json | |
echo "Ava ./uus.html veebilehitsejas, et näha tulemust." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment