Open tercerapersona opened 2 years ago
A way is to use xq.
Running
curl --silent https://www.rust-lang.org/ | htmlq '#get-help' | xq .
you have
{
"div": {
"@class": "flex flex-column mw8 w-100 measure-wide-l pv2 pv5-m pv2-ns ph4-m ph4-l",
"@id": "get-help",
"h4": "Get help!",
"ul": {
"li": [
{
"a": {
"@href": "/learn",
"#text": "Documentation"
}
},
{
"a": {
"@href": "http://forge.rust-lang.org",
"#text": "Rust Forge (Contributor Documentation)"
}
},
{
"a": {
"@href": "https://users.rust-lang.org",
"#text": "Ask a Question on the Users Forum"
}
},
{
"a": {
"@href": "http://ping.rust-lang.org",
"#text": "Check Website Status"
}
}
]
},
"div": {
"@class": "languages",
"label": {
"@class": "hidden",
"@for": "language-footer",
"#text": "Language"
},
"select": {
"@id": "language-footer",
"option": [
{
"@title": "English (en-US)",
"@value": "en-US",
"#text": "English (en-US)"
},
{
"@title": "Español (es)",
"@value": "es",
"#text": "Español (es)"
},
{
"@title": "Français (fr)",
"@value": "fr",
"#text": "Français (fr)"
},
{
"@title": "Italiano (it)",
"@value": "it",
"#text": "Italiano (it)"
},
{
"@title": "日本語 (ja)",
"@value": "ja",
"#text": "日本語 (ja)"
},
{
"@title": "Português (pt-BR)",
"@value": "pt-BR",
"#text": "Português (pt-BR)"
},
{
"@title": "Русский (ru)",
"@value": "ru",
"#text": "Русский (ru)"
},
{
"@title": "Türkçe (tr)",
"@value": "tr",
"#text": "Türkçe (tr)"
},
{
"@title": "简体中文 (zh-CN)",
"@value": "zh-CN",
"#text": "简体中文 (zh-CN)"
},
{
"@title": "正體中文 (zh-TW)",
"@value": "zh-TW",
"#text": "正體中文 (zh-TW)"
}
]
}
}
}
}
Is there any progress here?
Have you thought about adding JSON output?
It would be great to curl + parse with
htmlq
and finally pipe tojq
;)