Skip to content

Instantly share code, notes, and snippets.

@mxcoder
Last active October 4, 2017 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxcoder/883c9a99cb3b842cbc52bbe75644f2d8 to your computer and use it in GitHub Desktop.
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
#!/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