【发布时间】:2015-10-25 01:50:48
【问题描述】:
我有一个小问题,希望有人能帮我解决这个问题。基本上,我有一个从 Youtube 下载缩略图的脚本,它可以正常工作,但现在我希望它更高级,并且可以选择提供播放列表的 url(系统选择已经制作)并获取 html 页面播放列表,然后找到所有包含 /watch?v=(视频的 url)的行,然后取出除视频 id(v= 之后的一系列字符)之外的所有内容。
现在我的下载系统可以正常工作了,我只是找不到使用 /watch?v= 获取线路的方法。
这是我下载网页和查找行部分的代码
read -p "Enter the url of the playlist : " link #Ask for url
content=$(curl $link --silent) #Downloads the webpage
contentxt="$basedir/playlist_page.txt" #Creates a file to store the webpage
echo $content > "$contentxt" #Saves the webpage into the file
url=$(grep -F "/watch?v=" $contentxt) #Find a line with the /watch?v=
echo $url #Displays that line containing the url to be used later
谢谢!
【问题讨论】:
标签: string bash shell grep find