User:Asj/Doing stuff with mediawiki api: Difference between revisions
< User:Asj
Created page with "notes mainly for myself == getting template property == using jq and xq <pre> curl -s "https://wiki.nottinghack.org.uk/api.php?action=parse&page=Rosey&contentmodel=json&prop=parsetree&format=json" | jq -r '.parse.parsetree."*"' | xq -x "//template/title[contains(text(), 'Tool')]/parent::template/part/name[contains(text(), 'image')]/parent::part/value" </pre> == getting an image url for image page == <pre> curl -s "https://wiki.nottinghack.org.uk/api.php?action=query..." |
(No difference)
|
Latest revision as of 19:38, 4 April 2025
notes mainly for myself
getting template property
using jq and xq
curl -s "https://wiki.nottinghack.org.uk/api.php?action=parse&page=Rosey&contentmodel=json&prop=parsetree&format=json" | jq -r '.parse.parsetree."*"' | xq -x "//template/title[contains(text(), 'Tool')]/parent::template/part/name[contains(text(), 'image')]/parent::part/value"
getting an image url for image page
curl -s "https://wiki.nottinghack.org.uk/api.php?action=query&prop=imageinfo&titles=file:Printer%20Rosey.jpg&prop=imageinfo&iiprop=url&format=json" | jq -r '.query.pages[].imageinfo[0].url'