
などのコマンドライン Web ブラウザーがあることは知っていますw3m
lynx
。しかし、検索クエリを印刷するだけのよりシンプルなツールを探しています。 と似ていcurl
ますが、よりきれいにフォーマットされています。
走ったらhttps://www.youtube.com/results?search_query=linux
次のようなものが得られます:
Top 3 Best Desktop Linux Distros | 2019 Edition
https://www.youtube.com/watch?v=vZ7nI2im4Yg
_________________________________________________
The Next Ubuntu? - Clear Linux First Impressions
https://www.youtube.com/watch?v=UuCxCLFDfwM
_________________________________________________
The Next Ubuntu? - Clear Linux First Impressions
https://www.youtube.com/watch?v=FUGd99GRAfo
_________________________________________________
もっと簡単に言えばタイトルとリンクだけ
編集:コメントのおかげで、私はさらに調査をしましたウェブスクレイピングそして、見つけたこのコードwget
パッケージの 2 つのアプリケーションをhtml-xml-utils
と組み合わせて使用しますlynx
。
link="https://www.youtube.com/results?search_query=linux"
wget "$link" -O- |
hxnormalize -x |
hxselect -i "div." | #in this line I'm missing the proper pattern
lynx -stdin -dump
youtube.com 検索で表示されるタイトルを調べると、次のようになります。
<div id="title-wrapper" class="style-scope ytd-video-renderer">
<h3 class="title-and-badge style-scope ytd-video-renderer">
<ytd-badge-supported-renderer class="style-scope ytd-video-renderer" disable-upgrade="" hidden="">
<dom-repeat id="repeat" as="badge" class="style-scope ytd-badge-supported-renderer" style="display: none;"><template></template></dom-repeat>
</ytd-badge-supported-renderer>
<a id="video-title" class="yt-simple-endpoint style-scope ytd-video-renderer" title="What is Linux?" href="/watch?v=zA3vmx0GaO8" aria-l$
What is Linux?
</a>
</h3>
<div id="menu" class="style-scope ytd-video-renderer"></div>
</div>
hxselect
タイトルとリンクを grep するためにどのようなパターンを使用すればよいかわかりません。