Skip to content

Instantly share code, notes, and snippets.

@nicholasspencer
Last active April 18, 2019 19:55
Show Gist options
  • Save nicholasspencer/3aeecae5c0014f9cf211721f3b8e3fb0 to your computer and use it in GitHub Desktop.
Save nicholasspencer/3aeecae5c0014f9cf211721f3b8e3fb0 to your computer and use it in GitHub Desktop.
curl | pup | jq script to scrape etsy type information
#!/usr/bin/env bash
scrape_type() {
curl https://www.etsy.com/developers/documentation/reference/$1 | pup 'table[id^="resource_fields"] tr:not(:first-child) json{}' | jq '.[] | {"property": .children[0].children[0].text, "type": .children[3].children[0].children[0].text, "secondaryType": (.children[3].children[0].text | try gsub("[\\(\\) ]"; "") catch null) }'
}
scrape_type $1
exit 0
# ./bin/scrape_type.sh apimethod
# Produces:
#
# {
# "property": "name",
# "type": "string",
# "secondaryType": null
# }
# {
# "property": "uri",
# "type": "string",
# "secondaryType": null
# }
# {
# "property": "params",
# "type": null,
# "secondaryType": null
# }
# {
# "property": "defaults",
# "type": null,
# "secondaryType": null
# }
# {
# "property": "type",
# "type": "string",
# "secondaryType": null
# }
# {
# "property": "visibility",
# "type": "string",
# "secondaryType": null
# }
# {
# "property": "http_method",
# "type": "string",
# "secondaryType": null
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment