從命令列瀏覽互聯網

從命令列瀏覽互聯網

我知道有類似的命令列網頁瀏覽器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中的兩個應用程式:html-xml-utilslynx

   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 標題和連結。

相關內容