query web
for network
execute selector query on html/web
This command requires a plugin
The query web
command resides in the query
plugin. To use this command, you must install and register nu_plugin_query
. See the Plugins chapter in the book for more information.
Signature
> query web {flags}
Flags
--query, -q {string}
: selector query--as-html, -m
: return the query output as html--attribute, -a {any}
: downselect based on the given attribute--as-table, -t {list<string>}
: find table based on column header list--inspect, -i
: run in inspect mode to provide more information for determining column headers
Input/output types:
input | output |
---|---|
any | any |
Examples
Retrieve all <header>
elements from phoronix.com website
> http get https://phoronix.com | query web --query 'header' | flatten
Retrieve a html table from Wikipedia and parse it into a nushell table using table headers as guides
> http get https://en.wikipedia.org/wiki/List_of_cities_in_India_by_population |
query web --as-table [City 'Population(2011)[3]' 'Population(2001)[3][a]' 'State or unionterritory' 'Reference']
Pass multiple css selectors to extract several elements within single query, group the query results together and rotate them to create a table
> http get https://www.nushell.sh | query web --query 'h2, h2 + p' | each {str join} | chunks 2 | each {rotate --ccw tagline description} | flatten
Retrieve a specific html attribute instead of the default text
> http get https://example.org | query web --query a --attribute href
Retrieve the OpenGraph properties (<meta property="og:...">
) from a web page
> http get https://www.rust-lang.org | query web --query 'meta[property^="og:"]' --attribute [ property content ]