Last active
July 5, 2020 09:04
-
-
Save framp/f6a6d3164108261d92fef9533b3f572b to your computer and use it in GitHub Desktop.
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
set url "http://www.cardenas-grancanaria.com/search-results.asp?FirstRecord=1&txtRC=R&txtOperacion=1&txtLocation=&txtPropType=1%2C2%2C3%2C4%2C+5%2C6%2C7%2C8%2C9%2C+19%2C20&txtBeds=&txtMinPrice=0&txtMaxPrice=&txtPool=&txtParking=&txtNewDev=&txtSeaView=&txtLux=False&txtI=False&txtSF=False&txtRF=False&pagesize=300&price_order=DESC" | |
curl $url | rg -o 'href\s*="([^"]+for-sale[^"]+)"' | sd '(^href="|"$)' '' | uniq > properties | |
xargs -n 1 curl -O < properties | |
rg -oe '(Type|Location|Bedrooms|Bathrooms|Build Size|Living Area|Price) : </b></td><td>(.*?)</td>' | sd "<[^<]*>" "" | sd " : " ":" | node -e 'console.log("ID;Type;Location;Bedrooms;Bathrooms;Build Siz;Living Area;Price") || console.log(Object.values(fs.readFileSync("/dev/stdin").toString().split("\\n").filter(Boolean).map(a => a.split(":")).reduce((acc, [id, type, val]) => ({ ...acc, [id]: { ...(acc[id] || {}), Id: id.replace(".htm", ""), [type]: val.trim().replace(/\\s+/g, " ") } }) , {})).filter(({ Price }) => Number(Price.split(" ")[0].replace(/\\./,""))).sort((a,b) => Number(a.Price.split(" ")[0].replace(/\./g,"")) - Number(b.Price.split(" ")[0].replace(/\\./g,""))).map(a => (`${a.Id}\\t${a.Type}\\t${a.Location}\\t${a.Bedrooms}\\t${a.Bathrooms}\\t${a["Build Size"]}\\t${a["Living Area"]}\\t${a.Price}`).replace(/\\t/g, ";")).join("\\n"))' | column -t -s';' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment