.png)
Linux Bash를 사용하는 경우 다음 명령을 사용하여 텍스트 파일을 변환하려면 어떻게 해야 합니까?
http://example.org/
https://en.wikipedia.org/wiki/Main_Page
https://www.youtube.com/watch?v=mGQFZxIuURE
입력하다:
http://example.org/ Example Domain
https://en.wikipedia.org/wiki/Main_Page Wikipedia, the free encyclopedia
https://www.youtube.com/watch?v=mGQFZxIuURE Mike Perry - The Ocean (ft. Shy Martin) - YouTube
또는 다음을 입력하세요:
http://example.org/
Example Domain
https://en.wikipedia.org/wiki/Main_Page
Wikipedia, the free encyclopedia
https://www.youtube.com/watch?v=mGQFZxIuURE
Mike Perry - The Ocean (ft. Shy Martin) - YouTube
?
어떻게 할 수 있습니까?
- 파일의 URL 목록에서 URL을 추출하고,
- 페이지를 로드하고,
- 페이지 제목을 추출하고,
- 같은 줄 또는 바로 다음 줄의 URL 뒤에 페이지 제목을 추가한 다음
목록의 각 후속 URL에 대해 1~4단계를 수행하시겠습니까?
Linux Bash를 사용하지 않는다면 또 무엇이 있을까요?
답변1
curl
헤헤강아지:
while IFS= read -r url
do
printf "%s " "$url"
curl -sL "$url" | # fetch the page
pup 'head title:first-of-type text{}' # get the text of the first title tag in head
done < input