User:Asj/Doing stuff with mediawiki api

From Nottinghack Wiki
Revision as of 19:38, 4 April 2025 by Asj (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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'