Last active
October 4, 2017 03:46
-
-
Save mxcoder/883c9a99cb3b842cbc52bbe75644f2d8 to your computer and use it in GitHub Desktop.
Bash script to extract information from popup for http://data.seduvi.cdmx.gob.mx:8080/ventanillaUnica/dro/buscarPorNombre
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
#!/bin/bash | |
# prerequisites: | |
# libs: xsv, curl, dity, xpath, sed, paste | |
# files: procesado.csv contains in column 1 the ID for the DRO and column 3 the url of the popup | |
for line in `xsv select 1,3 --no-headers procesado.csv`; do | |
# skip first line, need to research if theres an option for it | |
if [ "${line}" != "No.,Datos" ]; then | |
# split $line into $data array[id,url] | |
data=(${line//,/ }) | |
# echo "ID, parsed html" | |
echo ${data[0]},`curl -s "${data[1]}" | tidy -q -asxml -n -f /dev/null | xpath -e "(/html/body/div/div/table/tbody/tr[5]/td[2]|/html/body/div/div/table/tbody/tr[6]/td[2])/text()" -q | sed '/^$/d' | paste -s -d ' '` | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment