
나는 등과 같은 명령줄 웹 브라우저가 있다는 것을 알고 있습니다 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-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
제목과 링크를 파악하기 위해 어떤 패턴을 사용해야 할지 모르겠습니다 .